Module: ActiveGraph::Node::IdProperty::Accessor::ClassMethods

Defined in:
lib/active_graph/node/id_property/accessor.rb

Instance Method Summary collapse

Instance Method Details

#default_propertiesHash<Symbol,Proc>

Returns:

  • (Hash<Symbol,Proc>)


38
39
40
# File 'lib/active_graph/node/id_property/accessor.rb', line 38

def default_properties
  @default_property ||= {}
end

#default_properties_keysObject



42
43
44
# File 'lib/active_graph/node/id_property/accessor.rb', line 42

def default_properties_keys
  @default_properties_keys ||= default_properties.keys
end

#default_property(name, &block) ⇒ Object

TODO: Move this to the DeclaredProperties



32
33
34
35
# File 'lib/active_graph/node/id_property/accessor.rb', line 32

def default_property(name, &block)
  reset_default_properties(name) if default_properties.respond_to?(:size)
  default_properties[name] = block
end

#default_property_keyObject



27
28
29
# File 'lib/active_graph/node/id_property/accessor.rb', line 27

def default_property_key
  @default_property_key ||= default_properties_keys.first
end

#default_property_values(instance) ⇒ Object



55
56
57
58
59
# File 'lib/active_graph/node/id_property/accessor.rb', line 55

def default_property_values(instance)
  default_properties.each_with_object({}) do |(key, block), result|
    result[key] = block.call(instance)
  end
end

#reset_default_properties(name_to_keep) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/active_graph/node/id_property/accessor.rb', line 46

def reset_default_properties(name_to_keep)
  default_properties.each_key do |property|
    @default_properties_keys = nil
    undef_method(property) unless property == name_to_keep
  end
  @default_properties_keys = nil
  @default_property = {}
end