Module: Neo4j::Shared::Property
Defined Under Namespace
Modules: ClassMethods
Classes: MultiparameterAssignmentError, UndefinedPropertyError
Constant Summary
Constants included
from Attributes
Attributes::DEPRECATED_OBJECT_METHODS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#attribute_before_type_cast
Methods included from Attributes
#==, #attributes, #query_attribute, #write_attribute
#add_undeclared_property, #assign_attributes, #attributes=
Instance Attribute Details
#_persisted_obj ⇒ Object
Returns the value of attribute _persisted_obj.
12
13
14
|
# File 'lib/neo4j/shared/property.rb', line 12
def _persisted_obj
@_persisted_obj
end
|
Instance Method Details
#initialize(attributes = nil) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'lib/neo4j/shared/property.rb', line 30
def initialize(attributes = nil)
attributes = process_attributes(attributes)
modded_attributes = inject_defaults!(attributes)
validate_attributes!(modded_attributes)
writer_method_props = (modded_attributes)
send_props(writer_method_props)
self.undeclared_properties = attributes
@_persisted_obj = nil
end
|
#inject_defaults!(starting_props) ⇒ Object
42
43
44
45
|
# File 'lib/neo4j/shared/property.rb', line 42
def inject_defaults!(starting_props)
return starting_props if self.class.declared_properties.declared_property_defaults.empty?
self.class.declared_properties.inject_defaults!(self, starting_props || {})
end
|
#inspect ⇒ Object
21
22
23
24
25
26
27
28
|
# File 'lib/neo4j/shared/property.rb', line 21
def inspect
attribute_descriptions = inspect_attributes.map do |key, value|
"#{Neo4j::ANSI::CYAN}#{key}: #{Neo4j::ANSI::CLEAR}#{value.inspect}"
end.join(', ')
separator = ' ' unless attribute_descriptions.empty?
"#<#{Neo4j::ANSI::YELLOW}#{self.class.name}#{Neo4j::ANSI::CLEAR}#{separator}#{attribute_descriptions}>"
end
|
#mutations_from_database ⇒ Object
TODO: Set @attribute correctly using class ActiveModel::Attribute, and after that remove mutations_from_database and other ActiveModel::Dirty overrided methods
16
17
18
19
|
# File 'lib/neo4j/shared/property.rb', line 16
def mutations_from_database
@mutations_from_database ||=
defined?(ActiveModel::ForcedMutationTracker) ? ActiveModel::ForcedMutationTracker.new(self) : ActiveModel::NullMutationTracker.instance
end
|
#read_attribute(name) ⇒ Object
Also known as:
[]
47
48
49
|
# File 'lib/neo4j/shared/property.rb', line 47
def read_attribute(name)
respond_to?(name) ? send(name) : nil
end
|
#reload_properties!(properties) ⇒ Object
57
58
59
60
|
# File 'lib/neo4j/shared/property.rb', line 57
def reload_properties!(properties)
@attributes = nil
convert_and_assign_attributes(properties)
end
|
#send_props(hash) ⇒ Object
52
53
54
55
|
# File 'lib/neo4j/shared/property.rb', line 52
def send_props(hash)
return hash if hash.blank?
hash.each { |key, value| send("#{key}=", value) }
end
|
#undeclared_properties=(_) ⇒ Object
40
|
# File 'lib/neo4j/shared/property.rb', line 40
def undeclared_properties=(_); end
|