Class: RubyRest::Atom::NestedProperty

Inherits:
SimpleProperty show all
Defined in:
lib/rubyrest/atom.rb

Constant Summary collapse

NESTED_PROPERTY_SEPARATOR =
'_'.freeze

Instance Method Summary collapse

Methods inherited from SimpleProperty

#app, #format, #initialize, #object_value, #parse, #tag, #value_from_model, #value_from_xml, #xml_value

Constructor Details

This class inherits a constructor from RubyRest::Atom::SimpleProperty

Instance Method Details

#bind(object, options, value) ⇒ Object

[View source]

190
191
192
193
194
195
196
# File 'lib/rubyrest/atom.rb', line 190

def bind( object, options, value  )
  prop = options[:property]
  tokens = prop.to_s.split( NESTED_PROPERTY_SEPARATOR )
  property = tokens[0].intern
  nested_prop = tokens[1]
  object[property]= app.resource( property ).method( "first_by_#{nested_prop}").call( value )[:id]
end