Sha256: 028a694bca583b9a0ac1e95e1894e9a0ee489296759d1a00132cfa5550cb2d40
Contents?: true
Size: 999 Bytes
Versions: 1
Compression:
Stored size: 999 Bytes
Contents
require 'hari/node/repository' require 'hari/node/queries' require 'hari/node/serialization' require 'hari/node/index' 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 after_update { reindex } after_create { reindex force_index: true } after_destroy { remove_from_indexes } def generate_id unless model_id.present? begin self.model_id = SecureRandom.hex(8) end until !Hari.redis.exists(node_key) end node_key end def node_key "#{node_type}##{model_id}" end def node_type @node_type || self.class.node_type end def self.node_type self.to_s.underscore end def self.indexed_properties properties.select { |p| p.options[:index] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hari-0.0.5 | lib/hari/node.rb |