Class: RubySol::MappingSet
- Inherits:
-
Object
- Object
- RubySol::MappingSet
- Defined in:
- lib/ruby_sol/class_mapping.rb
Overview
Container for all mapped classes
Instance Method Summary collapse
-
#get_as_class_name(class_name) ⇒ Object
Returns the AS class name for the given ruby class name, returing nil if not found.
-
#get_ruby_class_name(class_name) ⇒ Object
Returns the ruby class name for the given AS class name, returing nil if not found.
-
#initialize ⇒ MappingSet
constructor
Creates a mapping set object and populates the default mappings.
-
#map(params) ⇒ Object
Map a given AS class to a ruby class.
-
#map_defaults ⇒ Object
Adds required mapping configs, calling map for the required base mappings.
Constructor Details
#initialize ⇒ MappingSet
Creates a mapping set object and populates the default mappings
21 22 23 24 25 |
# File 'lib/ruby_sol/class_mapping.rb', line 21 def initialize @as_mappings = {} @ruby_mappings = {} map_defaults end |
Instance Method Details
#get_as_class_name(class_name) ⇒ Object
Returns the AS class name for the given ruby class name, returing nil if not found
57 58 59 |
# File 'lib/ruby_sol/class_mapping.rb', line 57 def get_as_class_name class_name #:nodoc: @ruby_mappings[class_name.to_s] end |
#get_ruby_class_name(class_name) ⇒ Object
Returns the ruby class name for the given AS class name, returing nil if not found
63 64 65 |
# File 'lib/ruby_sol/class_mapping.rb', line 63 def get_ruby_class_name class_name #:nodoc: @as_mappings[class_name.to_s] end |
#map(params) ⇒ Object
Map a given AS class to a ruby class.
Use fully qualified names for both.
Example:
m.map :as => 'com.example.Date', :ruby => 'Example::Date'
49 50 51 52 53 |
# File 'lib/ruby_sol/class_mapping.rb', line 49 def map params [:as, :ruby].each {|k| params[k] = params[k].to_s} # Convert params to strings @as_mappings[params[:as]] = params[:ruby] @ruby_mappings[params[:ruby]] = params[:as] end |
#map_defaults ⇒ Object
Adds required mapping configs, calling map for the required base mappings. Designed to allow extenders to take advantage of required default mappings.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ruby_sol/class_mapping.rb', line 29 def map_defaults # map :as => 'flex.messaging.messages.AbstractMessage', :ruby => 'RubySol::Values::AbstractMessage' # map :as => 'flex.messaging.messages.RemotingMessage', :ruby => 'RubySol::Values::RemotingMessage' # map :as => 'flex.messaging.messages.AsyncMessage', :ruby => 'RubySol::Values::AsyncMessage' # map :as => 'DSA', :ruby => 'RubySol::Values::AsyncMessageExt' # map :as => 'flex.messaging.messages.CommandMessage', :ruby => 'RubySol::Values::CommandMessage' # map :as => 'DSC', :ruby => 'RubySol::Values::CommandMessageExt' # map :as => 'flex.messaging.messages.AcknowledgeMessage', :ruby => 'RubySol::Values::AcknowledgeMessage' # map :as => 'DSK', :ruby => 'RubySol::Values::AcknowledgeMessageExt' # map :as => 'flex.messaging.messages.ErrorMessage', :ruby => 'RubySol::Values::ErrorMessage' self end |