module Representable::YAML
Public Class Methods
Source
# File lib/representable/yaml.rb, line 9 def self.included(base) base.class_eval do include Representable register_feature Representable::YAML extend ClassMethods end end
Public Instance Methods
Source
# File lib/representable/yaml.rb, line 23 def from_yaml(doc, options={}) hash = Psych.load(doc) from_hash(hash, options, Binding) end
Also aliased as: parse
Source
# File lib/representable/yaml.rb, line 29 def to_ast(options={}) Psych::Nodes::Mapping.new.tap do |map| create_representation_with(map, options, Binding) end end
Returns a Nokogiri::XML object representing this object.
Source
# File lib/representable/yaml.rb, line 35 def to_yaml(*args) stream = Psych::Nodes::Stream.new stream.children << doc = Psych::Nodes::Document.new doc.children << to_ast(*args) stream.to_yaml end
Also aliased as: render