Class: RTunesU::HasNEntityCollectionProxy
- Inherits:
-
SubentityAssociationProxy
- Object
- SubentityAssociationProxy
- RTunesU::HasNEntityCollectionProxy
- Defined in:
- lib/rtunesu/associations.rb
Instance Attribute Summary collapse
-
#edits ⇒ Object
readonly
Returns the value of attribute edits.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Instance Method Summary collapse
- #<<(entity) ⇒ Object
- #[]=(index, entity) ⇒ Object
- #from_xml(name) ⇒ Object
-
#initialize(source_xml, owner, name) ⇒ HasNEntityCollectionProxy
constructor
A new instance of HasNEntityCollectionProxy.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(source_xml, owner, name) ⇒ HasNEntityCollectionProxy
Returns a new instance of HasNEntityCollectionProxy.
51 52 53 54 |
# File 'lib/rtunesu/associations.rb', line 51 def initialize(source_xml, owner, name) super self.from_xml(name) end |
Instance Attribute Details
#edits ⇒ Object (readonly)
Returns the value of attribute edits.
49 50 51 |
# File 'lib/rtunesu/associations.rb', line 49 def edits @edits end |
#target ⇒ Object (readonly)
Returns the value of attribute target.
49 50 51 |
# File 'lib/rtunesu/associations.rb', line 49 def target @target end |
Instance Method Details
#<<(entity) ⇒ Object
68 69 70 71 |
# File 'lib/rtunesu/associations.rb', line 68 def <<(entity) @target << entity @edits << entity end |
#[]=(index, entity) ⇒ Object
73 74 75 76 |
# File 'lib/rtunesu/associations.rb', line 73 def []=(index,entity) @target[index] = entity @entity[index] = entity end |
#from_xml(name) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/rtunesu/associations.rb', line 56 def from_xml(name) if @source_xml @target = @source_xml.collect {|el| "RTunesU::#{name}".constantize.new(:source_xml => el, :parent_handle => @owner.handle)} else @target = [] end end |
#to_xml(builder) ⇒ Object
64 65 66 |
# File 'lib/rtunesu/associations.rb', line 64 def to_xml(builder) self.edits.each {|entity| entity.to_xml(builder)} end |