Property

Constants

  • DATE_KEY_REGEX

Methods

#[]

Returning nil when we get ActiveAttr::UnknownAttributeError from ActiveAttr

def read_attribute(name)
  super(name)
rescue ActiveAttr::UnknownAttributeError
  nil
end
#_persisted_obj

Returns the value of attribute _persisted_obj

def _persisted_obj
  @_persisted_obj
end
#initialize

TODO: Remove the commented :super entirely once this code is part of a release. It calls an init method in active_attr that has a very negative impact on performance.

def initialize(attributes = nil)
  attributes = process_attributes(attributes)
  @relationship_props = self.class.extract_association_attributes!(attributes)
  modded_attributes = inject_defaults!(attributes)
  validate_attributes!(modded_attributes)
  writer_method_props = extract_writer_methods!(modded_attributes)
  send_props(writer_method_props)
  @_persisted_obj = nil
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

Returning nil when we get ActiveAttr::UnknownAttributeError from ActiveAttr

def read_attribute(name)
  super(name)
rescue ActiveAttr::UnknownAttributeError
  nil
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