lib/representable/yaml.rb in representable-1.2.5 vs lib/representable/yaml.rb in representable-1.2.6

- old
+ new

@@ -1,10 +1,12 @@ -require 'representable' +require 'representable/hash' require 'representable/bindings/yaml_bindings' module Representable module YAML + include Hash + def self.binding_for_definition(definition) return CollectionBinding.new(definition) if definition.array? #return HashBinding.new(definition) if definition.hash? and not definition.options[:use_attributes] # FIXME: hate this. #return AttributeHashBinding.new(definition) if definition.hash? and definition.options[:use_attributes] #return AttributeBinding.new(definition) if definition.attribute @@ -26,26 +28,18 @@ # Accepts a block yielding the currently iterated Definition. If the block returns false # the property is skipped. # # Example: # band.from_xml("<band><name>Nofx</name></band>") - def from_xml(*args, &block) - create_represented(*args, &block).from_xml(*args) + def from_yaml(*args, &block) + create_represented(*args, &block).from_yaml(*args) end - - def from_node(*args, &block) - create_represented(*args, &block).from_node(*args) - end end def from_yaml(doc, *args) hash = Psych.load(doc) from_hash(hash, *args) - end - - def from_hash(hash, options={}) - update_properties_from(hash, options, YAML) end # Returns a Nokogiri::XML object representing this object. def to_ast(options={}) #root_tag = options[:wrap] || representation_wrap