Class: RestfulX::AMF::ClassMapping
- Inherits:
-
Object
- Object
- RestfulX::AMF::ClassMapping
- Defined in:
- lib/restfulx/amf/class_mapping.rb
Defined Under Namespace
Classes: MappingSet
Instance Method Summary collapse
-
#default_as_prefix ⇒ Object
Return default ActionScript prefix to use.
-
#default_as_prefix=(value) ⇒ Object
Set the default ActionScript prefix (typically a package e.g. com.foobar) to use for all models.
-
#define {|mappings| ... } ⇒ Object
Define class mappings in the block.
-
#get_as_class_name(obj) ⇒ Object
Returns the AS class name for the given ruby object.
-
#get_ruby_class_name(as_class_name) ⇒ Object
Return ruby model class name for a given ActionScript model class name.
Instance Method Details
#default_as_prefix ⇒ Object
Return default ActionScript prefix to use. This is recommended compared to defining mappings manually
69 70 71 |
# File 'lib/restfulx/amf/class_mapping.rb', line 69 def default_as_prefix mappings.default_as_prefix end |
#default_as_prefix=(value) ⇒ Object
Set the default ActionScript prefix (typically a package e.g. com.foobar) to use for all models
75 76 77 |
# File 'lib/restfulx/amf/class_mapping.rb', line 75 def default_as_prefix=(value) mappings.default_as_prefix = value end |
#define {|mappings| ... } ⇒ Object
Define class mappings in the block. Block is passed a MappingSet object as the first parameter.
Example:
RestfulX::AMF::ClassMapper.define do |m|
m.map :as => 'AsClass', :ruby => 'RubyClass'
end
63 64 65 |
# File 'lib/restfulx/amf/class_mapping.rb', line 63 def define #:yields: mapping_set yield mappings end |
#get_as_class_name(obj) ⇒ Object
Returns the AS class name for the given ruby object. Will also take a string containing the ruby class name
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/restfulx/amf/class_mapping.rb', line 81 def get_as_class_name(obj) # Get class name if obj.is_a?(String) ruby_class_name = obj else ruby_class_name = obj.class.name end if obj.respond_to?(:unique_id) mappings.get_as_class_name(ruby_class_name) else nil end end |
#get_ruby_class_name(as_class_name) ⇒ Object
Return ruby model class name for a given ActionScript model class name
97 98 99 |
# File 'lib/restfulx/amf/class_mapping.rb', line 97 def get_ruby_class_name(as_class_name) mappings.get_ruby_class_name(as_class_name.to_s) end |