Class: RTunesU::HasNEntityCollectionProxy

Inherits:
SubentityAssociationProxy show all
Defined in:
lib/rtunesu/associations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#editsObject (readonly)

Returns the value of attribute edits.



49
50
51
# File 'lib/rtunesu/associations.rb', line 49

def edits
  @edits
end

#targetObject (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