Module: Neo4j::Shared::Property

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Dirty, MassAssignment, TypecastedAttributes
Included in:
ActiveNode::Property, ActiveRel::Property
Defined in:
lib/neo4j/shared/property.rb

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

Methods included from TypecastedAttributes

#attribute_before_type_cast

Methods included from Attributes

#==, #attributes, #query_attribute, #write_attribute

Methods included from MassAssignment

#add_undeclared_property, #assign_attributes, #attributes=

Instance Attribute Details

#_persisted_objObject (readonly)

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


27
28
29
30
31
32
33
34
35
# File 'lib/neo4j/shared/property.rb', line 27

def initialize(attributes = nil)
  attributes = process_attributes(attributes)
  modded_attributes = inject_defaults!(attributes)
  validate_attributes!(modded_attributes)
  writer_method_props = extract_writer_methods!(modded_attributes)
  send_props(writer_method_props)
  self.undeclared_properties = attributes
  @_persisted_obj = nil
end

#inject_defaults!(starting_props) ⇒ Object


39
40
41
42
# File 'lib/neo4j/shared/property.rb', line 39

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

#inspectObject


18
19
20
21
22
23
24
25
# File 'lib/neo4j/shared/property.rb', line 18

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_databaseObject


14
15
16
# File 'lib/neo4j/shared/property.rb', line 14

def mutations_from_database
  ActiveModel::NullMutationTracker.instance
end

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


44
45
46
# File 'lib/neo4j/shared/property.rb', line 44

def read_attribute(name)
  respond_to?(name) ? send(name) : nil
end

#reload_properties!(properties) ⇒ Object


54
55
56
57
# File 'lib/neo4j/shared/property.rb', line 54

def reload_properties!(properties)
  @attributes = nil
  convert_and_assign_attributes(properties)
end

#send_props(hash) ⇒ Object


49
50
51
52
# File 'lib/neo4j/shared/property.rb', line 49

def send_props(hash)
  return hash if hash.blank?
  hash.each { |key, value| send("#{key}=", value) }
end

#undeclared_properties=(_) ⇒ Object


37
# File 'lib/neo4j/shared/property.rb', line 37

def undeclared_properties=(_); end