Module: Neo4j::ActiveNode::IdProperty::Accessor::ClassMethods
- Defined in:
- lib/neo4j/active_node/id_property/accessor.rb
Instance Method Summary collapse
- #default_properties ⇒ Hash<Symbol,Proc>
- #default_properties_keys ⇒ Object
-
#default_property(name, &block) ⇒ Object
TODO: Move this to the DeclaredProperties.
- #default_property_key ⇒ Object
- #default_property_values(instance) ⇒ Object
- #reset_default_properties(name_to_keep) ⇒ Object
Instance Method Details
#default_properties ⇒ Hash<Symbol,Proc>
38 39 40 |
# File 'lib/neo4j/active_node/id_property/accessor.rb', line 38 def default_properties @default_property ||= {} end |
#default_properties_keys ⇒ Object
42 43 44 |
# File 'lib/neo4j/active_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/neo4j/active_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_key ⇒ Object
27 28 29 |
# File 'lib/neo4j/active_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/neo4j/active_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/neo4j/active_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 |