Property¶
Constants¶
- DATE_KEY_REGEX
- DEPRECATED_OBJECT_METHODS
Methods¶
#[]
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
- #attributes=
Mass update a model’s attributes
def attributes=(new_attributes) assign_attributes(new_attributes) end
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) @_persisted_obj = nil end
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
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
def read_attribute(name) respond_to?(name) ? send(name) : nil end
def reload_properties!(properties) @attributes = nil convert_and_assign_attributes(properties) end
def send_props(hash) return hash if hash.blank? hash.each { |key, value| send("#{key}=", value) } end