Sha256: 114ebc7a5504fe9e88f85603a500393caef4b8eed015b3994c92a22137f5011a

Contents?: true

Size: 653 Bytes

Versions: 2

Compression:

Stored size: 653 Bytes

Contents

require 'hari/node/repository'
require 'hari/node/queries'
require 'hari/node/serialization'

module Hari
  class Node < Entity
    include Hari::Node::Queries
    include Hari::Node::Repository
    extend  Hari::Node::Serialization

    property :model_id

    def initialize(attrs = {})
      attrs = { model_id: attrs } if attrs.kind_of?(::Fixnum)
      super
    end

    def generate_id
      return super unless model_id

      model_id.to_s.include?('#') ? model_id.to_s : "#{node_type}##{model_id}"
    end

    def node_type
      @node_type || self.class.node_type
    end

    def self.node_type
      self.to_s.underscore
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hari-0.0.4 lib/hari/node.rb
hari-0.0.3 lib/hari/node.rb