Sha256: da59a0bb9a3be17e6eca0981b5c453f103371317f8b7ef6411b30530719725c0

Contents?: true

Size: 905 Bytes

Versions: 10

Compression:

Stored size: 905 Bytes

Contents

module Representable::XML
  module Hash
    include Representable::XML
    
    def self.included(base)
      base.class_eval do
        include Representable
        extend ClassMethods
      end
    end
    
    
    module ClassMethods
      def values(options)
        hash :_self, options
      end
    end
    
    
    def create_representation_with(doc, options, format)
      bin   = representable_bindings_for(format).first
      bin.serialize_for(self)
    end
    
    def update_properties_from(doc, options, format)
      bin   = representable_bindings_for(format).first
      value = bin.deserialize_from(doc)
      replace(value)
    end
    
    # FIXME: refactor Definition so we can simply add options in #items to existing definition.
    def representable_attrs
      attrs = super
      attrs << Definition.new(:_self, :hash => true) if attrs.size == 0
      attrs
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
representable-1.2.1 lib/representable/xml/hash.rb
representable-1.2.0 lib/representable/xml/hash.rb
representable-1.1.7 lib/representable/xml/hash.rb
representable-1.1.6 lib/representable/xml/hash.rb
representable-1.1.5 lib/representable/xml/hash.rb
representable-1.1.4 lib/representable/xml/hash.rb
representable-1.1.3 lib/representable/xml/hash.rb
representable-1.1.2 lib/representable/xml/hash.rb
representable-1.1.1 lib/representable/xml/hash.rb
representable-1.1.0 lib/representable/xml/hash.rb