Class: RubyRest::Atom::SimpleProperty
- Inherits:
-
Object
- Object
- RubyRest::Atom::SimpleProperty
- Defined in:
- lib/rubyrest/atom.rb
Direct Known Subclasses
Instance Method Summary collapse
- #bind(object, options, value) ⇒ Object
- #format(object, options, xml) ⇒ Object
-
#initialize(parent) ⇒ SimpleProperty
constructor
A new instance of SimpleProperty.
- #object_value(object, options) ⇒ Object
- #parse(object, options, xml) ⇒ Object
- #tag(options) ⇒ Object
- #value_from_model(options, object) ⇒ Object
- #value_from_xml(options, xml) ⇒ Object
- #xml_value(object, options) ⇒ Object
Constructor Details
#initialize(parent) ⇒ SimpleProperty
Returns a new instance of SimpleProperty.
105 106 107 |
# File 'lib/rubyrest/atom.rb', line 105 def initialize( parent ) @parent = parent end |
Instance Method Details
#bind(object, options, value) ⇒ Object
124 125 126 |
# File 'lib/rubyrest/atom.rb', line 124 def bind( object, , value ) object.send [:property].to_s + "=", value end |
#format(object, options, xml) ⇒ Object
141 142 143 144 145 146 |
# File 'lib/rubyrest/atom.rb', line 141 def format( object, , xml ) return if [:bind] == :request value = value_from_model( , object ) new_element = xml.add_element( tag( ) ) new_element.add_text( value.to_s ) if value != nil end |
#object_value(object, options) ⇒ Object
114 115 116 |
# File 'lib/rubyrest/atom.rb', line 114 def object_value( object, ) object.send [:property] end |
#parse(object, options, xml) ⇒ Object
128 129 130 131 |
# File 'lib/rubyrest/atom.rb', line 128 def parse( object, , xml ) return if [:bind] == :response bind( object, , value_from_xml( , xml ) ) end |
#tag(options) ⇒ Object
109 110 111 112 |
# File 'lib/rubyrest/atom.rb', line 109 def tag( ) value = [:tag]||[:property] return value.to_s end |
#value_from_model(options, object) ⇒ Object
137 138 139 |
# File 'lib/rubyrest/atom.rb', line 137 def value_from_model( , object ) object_value( object, ).to_s end |
#value_from_xml(options, xml) ⇒ Object
133 134 135 |
# File 'lib/rubyrest/atom.rb', line 133 def value_from_xml( , xml ) xml_value( xml, ) end |
#xml_value(object, options) ⇒ Object
118 119 120 121 122 |
# File 'lib/rubyrest/atom.rb', line 118 def xml_value( object, ) required = true required = [:required] if [:required] != nil return object.get_value( tag( ), required ) end |