Module: Neo4j::UndeclaredProperties

Extended by:
ActiveSupport::Concern
Defined in:
lib/neo4j/undeclared_properties.rb

Overview

This mixin allows storage and update of undeclared properties in the included class

Instance Method Summary collapse

Instance Method Details

#add_undeclared_property(name, value) ⇒ Object



49
50
51
# File 'lib/neo4j/undeclared_properties.rb', line 49

def add_undeclared_property(name, value)
  (self.undeclared_properties ||= {})[name] = value
end

#props_for_createObject



35
36
37
# File 'lib/neo4j/undeclared_properties.rb', line 35

def props_for_create
  super.merge(undeclared_properties!)
end

#props_for_updateObject



39
40
41
# File 'lib/neo4j/undeclared_properties.rb', line 39

def props_for_update
  super.merge(undeclared_properties!)
end

#read_attribute(name) ⇒ Object Also known as: []



13
14
15
# File 'lib/neo4j/undeclared_properties.rb', line 13

def read_attribute(name)
  respond_to?(name) ? super(name) : read_undeclared_property(name.to_sym)
end

#read_undeclared_property(name) ⇒ Object



18
19
20
# File 'lib/neo4j/undeclared_properties.rb', line 18

def read_undeclared_property(name)
  _persisted_obj ? _persisted_obj.props[name] : (undeclared_properties && undeclared_properties[name])
end

#skip_update?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/neo4j/undeclared_properties.rb', line 31

def skip_update?
  super && undeclared_properties.blank?
end

#undeclared_properties!Object



43
44
45
46
47
# File 'lib/neo4j/undeclared_properties.rb', line 43

def undeclared_properties!
  undeclared_properties || {}
ensure
  self.undeclared_properties = nil
end

#validate_attributes!(_) ⇒ Object



10
11
# File 'lib/neo4j/undeclared_properties.rb', line 10

def validate_attributes!(_)
end

#write_attribute(name, value) ⇒ Object Also known as: []=



22
23
24
25
26
27
28
# File 'lib/neo4j/undeclared_properties.rb', line 22

def write_attribute(name, value)
  if respond_to? "#{name}="
    super(name, value)
  else
    add_undeclared_property(name, value)
  end
end