Property

Constants

  • DATE_KEY_REGEX
  • DEPRECATED_OBJECT_METHODS

Methods

#==

Performs equality checking on the result of attributes and its type.

def ==(other)
  return false unless other.instance_of? self.class
  attributes == other.attributes
end

#[]

def read_attribute(name)
  respond_to?(name) ? send(name) : nil
end
#[]=

Write a single attribute to the model’s attribute hash.

def write_attribute(name, value)
  if respond_to? "#{name}="
    send "#{name}=", value
  else
    fail Neo4j::UnknownAttributeError, "unknown attribute: #{name}"
  end
end
#_persisted_obj

Returns the value of attribute _persisted_obj

def _persisted_obj
  @_persisted_obj
end
#assign_attributes

Mass update a model’s attributes

def assign_attributes(new_attributes = nil)
  return unless new_attributes.present?
  new_attributes.each do |name, value|
    writer = :"#{name}="
    send(writer, value) if respond_to?(writer)
  end
end
#attribute_before_type_cast

Read the raw attribute value

def attribute_before_type_cast(name)
  @attributes ||= {}
  @attributes[name.to_s]
end
#attributes

Returns a Hash of all attributes

def attributes
  attributes_map { |name| send name }
end
#attributes=

Mass update a model’s attributes

def attributes=(new_attributes)
  assign_attributes(new_attributes)
end

#creates_unique_option

def creates_unique_option
  self.class.creates_unique_option
end

#end_node

alias_method :end_node,   :to_node

#from_node_neo_id

alias_method :from_node_neo_id, :start_node_neo_id

#initialize

def initialize(attributes = nil)
  super(attributes)
end

#inject_defaults!

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

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

#read_attribute

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

#rel_type

def type
  self.class.type
end

#reload_properties!

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

#send_props

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

#start_node

alias_method :start_node, :from_node

#to_node_neo_id

alias_method :to_node_neo_id,   :end_node_neo_id

#type

def type
  self.class.type
end
#write_attribute

Write a single attribute to the model’s attribute hash.

def write_attribute(name, value)
  if respond_to? "#{name}="
    send "#{name}=", value
  else
    fail Neo4j::UnknownAttributeError, "unknown attribute: #{name}"
  end
end