Sha256: a7586bd09e11ccd46f81c0e33bc41b266fbbc0f87ca87a585064ecb39552fecf

Contents?: true

Size: 478 Bytes

Versions: 1

Compression:

Stored size: 478 Bytes

Contents

module Hari
  class Node < Entity
    module Serialization

      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

      private

      def source_class(source)
        source['id'].split('#').first.camelize.constantize
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hari-0.0.5 lib/hari/node/serialization.rb