Class: Dozuki::Mapper::Proxy
- Inherits:
-
Object
- Object
- Dozuki::Mapper::Proxy
- Defined in:
- lib/dozuki-mapper/proxy.rb
Instance Attribute Summary collapse
-
#from_node ⇒ Object
Returns the value of attribute from_node.
-
#receiver ⇒ Object
Returns the value of attribute receiver.
Instance Method Summary collapse
- #boolean(attribute) ⇒ Object
- #date(attribute) ⇒ Object
- #each(attribute, opts = {}) ⇒ Object
- #float(attribute) ⇒ Object
-
#initialize(receiver, node) ⇒ Proxy
constructor
A new instance of Proxy.
- #int(attribute) ⇒ Object
- #node(attribute, opts = {}) ⇒ Object
- #string(attribute) ⇒ Object
Constructor Details
#initialize(receiver, node) ⇒ Proxy
Returns a new instance of Proxy.
6 7 8 9 |
# File 'lib/dozuki-mapper/proxy.rb', line 6 def initialize(receiver, node) self.receiver = receiver self.from_node = node end |
Instance Attribute Details
#from_node ⇒ Object
Returns the value of attribute from_node.
4 5 6 |
# File 'lib/dozuki-mapper/proxy.rb', line 4 def from_node @from_node end |
#receiver ⇒ Object
Returns the value of attribute receiver.
4 5 6 |
# File 'lib/dozuki-mapper/proxy.rb', line 4 def receiver @receiver end |
Instance Method Details
#boolean(attribute) ⇒ Object
27 28 29 |
# File 'lib/dozuki-mapper/proxy.rb', line 27 def boolean(attribute) self.receiver.send("#{attribute}=", from_node.boolean("./#{attribute}")) end |
#date(attribute) ⇒ Object
19 20 21 |
# File 'lib/dozuki-mapper/proxy.rb', line 19 def date(attribute) self.receiver.send("#{attribute}=", from_node.date("./#{attribute}")) end |
#each(attribute, opts = {}) ⇒ Object
35 36 37 38 39 |
# File 'lib/dozuki-mapper/proxy.rb', line 35 def each(attribute, opts={}) from_node.each("./#{attribute}") do |node| receiver.send(opts[:to]) << opts[:as].from_node(node) end end |
#float(attribute) ⇒ Object
23 24 25 |
# File 'lib/dozuki-mapper/proxy.rb', line 23 def float(attribute) self.receiver.send("#{attribute}=", from_node.float("./#{attribute}")) end |
#int(attribute) ⇒ Object
15 16 17 |
# File 'lib/dozuki-mapper/proxy.rb', line 15 def int(attribute) self.receiver.send("#{attribute}=", from_node.int("./#{attribute}")) end |
#node(attribute, opts = {}) ⇒ Object
31 32 33 |
# File 'lib/dozuki-mapper/proxy.rb', line 31 def node(attribute, opts={}) self.receiver.send("#{attribute}=", opts[:as].from_node(from_node.get("./#{attribute}"))) end |
#string(attribute) ⇒ Object
11 12 13 |
# File 'lib/dozuki-mapper/proxy.rb', line 11 def string(attribute) self.receiver.send("#{attribute}=", from_node.string("./#{attribute}")) end |