Module: Hari::Node::Serialization

Included in:
Hari::Node
Defined in:
lib/hari/node/serialization.rb

Instance Method Summary collapse

Instance Method Details

#from_source(source) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/hari/node/serialization.rb', line 5

def from_source(source)
  return if source.blank?

  case source
  when ::String
    hash = Yajl::Parser.parse(source)
    source_class(hash).from_hash hash
  when ::Hash
    source_class(source).from_hash source
  end
end