Module: Representable::XML::Collection

Includes:
Representable::XML
Defined in:
lib/representable/xml/collection.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Representable::XML

#from_node, #from_xml, #to_node, #to_xml

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
# File 'lib/representable/xml/collection.rb', line 5

def self.included(base)
  base.class_eval do
    include Representable
    extend ClassMethods
  end
end

Instance Method Details

#create_representation_with(doc, options, format) ⇒ Object



20
21
22
23
# File 'lib/representable/xml/collection.rb', line 20

def create_representation_with(doc, options, format)
  bin   = representable_bindings_for(format, options).first
  bin.write(doc, self)
end

#representable_attrsObject

FIXME: refactor Definition so we can simply add options in #items to existing definition.



32
33
34
35
36
# File 'lib/representable/xml/collection.rb', line 32

def representable_attrs
  attrs = super
  attrs << Definition.new(:_self, :collection => true) if attrs.size == 0
  attrs
end

#update_properties_from(doc, options, format) ⇒ Object



25
26
27
28
29
# File 'lib/representable/xml/collection.rb', line 25

def update_properties_from(doc, options, format)
  bin   = representable_bindings_for(format, options).first
  value = bin.deserialize_from(doc.search("./*")) # FIXME: use Binding#read.
  replace(value)
end