Module: Representable::ClassMethods::Declarations
- Defined in:
- lib/representable.rb
Instance Method Summary collapse
- #definition_class ⇒ Object
-
#representable_bindings ⇒ Object
Returns bindings for all properties.
-
#representable_collection(name, options = {}) ⇒ Object
Declares a represented document node collection.
-
#representable_property(*args) ⇒ Object
Declares a represented document node, which is usually a XML tag or a JSON key.
Instance Method Details
#definition_class ⇒ Object
45 46 47 |
# File 'lib/representable.rb', line 45 def definition_class Definition end |
#representable_bindings ⇒ Object
Returns bindings for all properties.
50 51 52 |
# File 'lib/representable.rb', line 50 def representable_bindings representable_attrs.map {|attr| binding_for_definition(attr) } end |
#representable_collection(name, options = {}) ⇒ Object
Declares a represented document node collection.
Examples:
representable_collection :products
representable_collection :products, :from => :item
representable_collection :products, :as => Product
74 75 76 77 |
# File 'lib/representable.rb', line 74 def representable_collection(name, ={}) [:collection] = true representable_property(name, ) end |
#representable_property(*args) ⇒ Object
Declares a represented document node, which is usually a XML tag or a JSON key.
Examples:
representable_property :name
representable_property :name, :from => :title
representable_property :name, :as => Name
61 62 63 64 65 |
# File 'lib/representable.rb', line 61 def representable_property(*args) attr = add_representable_property(*args) attr_reader(attr.getter) attr_writer(attr.getter) end |