⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rubyamf_config.rb

📁 Flex for rails的开发demo源码
💻 RB
字号:
require 'app/configuration'module RubyAMF  module Configuration    #set the service path used in all requests    RubyAMF::App::RequestStore.service_path = File.expand_path(RAILS_ROOT) + '/app/controllers'    #=> CLASS MAPPING CONFIGURATION    #    # 'path' defines the search location for incoming custom class that aren't of type active_record.    # For example, if you defined a class as [RemoteClass(alias="vo.MyVO")], there should be a ruby    # file in app/vo/MyVO.rb. The path is defined like so:  RAILS_ROOT + vo_path + remote_class_package    # This only matters if you're using VO's that aren't of type active_record    ClassMappings.path = 'app'        #=> FLEX DATE CONVERSION    # Specify if you want to use DateTime instead of Time for converting Flex Date Data Types    ClassMappings.use_ruby_date_time = false    #=> USE ARRAY COLLECTION    # By setting this to true, you opt in to using array collections for all the arrays generated by the body of your request.    # Note: This only works for amf3 with Remote Object, NOT with Net Connection.    ClassMappings.use_array_collection = false        #=>CHECK FOR ASSOCIATIONS    # If you do no specify the associations you want to load in the ClassMappings, then set this to true if you want    # RubyAMF to pick up eager-loaded associations. For large active record collections, it is suggested not to use this     # feature, but rather to specify the specific associations you would like loaded.    ClassMappings.check_for_associations = true          #=> GLOBAL PROPERTY IGNORING    # By putting attribute names into this array, you opt in to globally ignore these properties on incoming objects.    # If you want to ignore specific properties on certain objects, use the :ignore_fields property in a     # Class Mapping definition (see CLASS MAPPING DEFINITIONS)    ClassMappings.ignore_fields = ['created_at','created_on','updated_at','updated_on']        #=> CLASS MAPPING DEFINITIONS    # A Class Mapping definition conists of at least these two properties:    # :actionscript   # The incoming action script class to watch for    # :ruby           # The ruby class to turn it into    #    #=> Optional value object properties:    # :type                 # Used to spectify the type of VO, valid options are 'active_record', 'custom',  (or don't specify at all)    # :associations     # Specify which associations to read on the active record (only applies to active records)    # :attributes        # Specifically which attributes to include in the serialization    # :ignore_fields  # An array of field names you want to ignore on incoming classes    #    # If you are using ActiveRecord VO's you do not need to specify a fully qualified class path to the model, you can just define the class name,     # EX: ClassMappings.register(:actionscript => 'vo.Person', :ruby => 'Person', :type => 'active_record')    #    # If you are using custom VO's you would need to specify the fully qualified class path to the file    # EX: ClassMappings.register(:actionscript => 'vo.Person', :ruby => 'org.mypackage.Person')    #    #ClassMappings.register(:actionscript => 'Person', :ruby => 'Person', :type => 'active_record', :attributes => ["id", "address_id"])    #ClassMappings.register(:actionscript => 'User', :ruby => 'User', :type => 'active_record', :associations=> ["addresses", "credit_cards"])    #ClassMappings.register(:actionscript => 'Address', :ruby => 'Address', :type => 'active_record')    #    # CLASS MAPPING SCOPE (ADVANCED USAGE)    # You can also specify a class mapping scope if you want. For example, lets say you need certain attributes for a book when you are viewing a book    # in flex as opposed to editing a book (where you would need more parameters). You can define a scope mapping parameter for ":attributes"    # or for ":associations." You're mapping would look something like this.    # ClassMappings.register(    #  :actionscript  => 'com.mixbook.vo.books.BookVO',          #   :ruby          => 'Book',          #   :type          => 'active_record',    #   :associations  => ["access_info", "pages", "page_ratio"],      #   :attributes    => {:viewing => ["description", "title"], :editing => ["id","published_at","theme_id"] }    <=== notice the hash instead of an array    #    # Now, to call the class mapping scope of editing (you are sending objects to the editing application), your controller call would look like this:    # EX: render :amf => book, :class_mapping_scope => :editing    #    # You can also specify a default scope to use. If you don't set this and you don't specify a class mapping scope on an attribute or association, then     # it will not have a scope to use and will not add any attributes or associations (whichever it cant match) to that association.    # ClassMappings.default_mapping_scope = :viewing        #=> FORCE ACTIVE RECORD IDS    # includes the id field for activerecord objects even if you don't specify it when using custom attributes. This is important for deserialization    # where ids are needed to keep active record association integrity.    ClassMappings.force_active_record_ids = true         #=> CASE TRANSLATIONS    # Most actionscript uses camelCase instead of snake_case. Set ClassMappings.translate_case to true if want translations to occur.    # The translations only occur on object properties    # An incoming property like: myProperty gets turned into my_property    # An outgoing property like my_property gets turned into myProperty    ClassMappings.translate_case = false        #=> RETURN TOP LEVEL HASH    # For those scaffolding users out there, who want the top-level object to come as a hash so scaffolding works out of the box.    ParameterMappings.scaffolding = false        #=> INCOMING REMOTING PARAMETER MAPPINGS    # Incoming Remoting Parameter mappings allow you to map an incoming requests parameters into rails' params hash    #    # Here's an example:    # ParameterMappings.register(    #   :controller => :UserController,    #   :action => :find_friend,    #   :params => { :friend => "[0].friend" }    # )    #     # That example maps the first remoting parameters "friend" property into params[:friend]    #    # [0] represents an array accessor    # . represents object notation.    # So you could do this: "[0][0].users[5].firstname" and it will take the value    # from your remoting parameters: [0][0].users[5].firstname    #     # Also, you can have it apply globally to an entire controller, just leave out the action key    #    # Here's an example:    # ParameterMappings.register(    #   :controller => :UserController,    #   :params => { :friend => "[0].friend" }    # )    # Now, everything going to the UserController will convert the first remoting parameters friend property     # to friend in EVERY ACTION  endend

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -