ClassMethods

Constants

Methods

#attribute!

def attribute!(name, options = {})
  super(name, options)
  define_method("#{name}=") do |value|
    typecast_value = typecast_attribute(_attribute_typecaster(name), value)
    send("#{name}_will_change!") unless typecast_value == read_attribute(name)
    super(value)
  end
end
#attributes_nil_hash

an extra call to a slow dependency method.

def attributes_nil_hash
  declared_property_manager.attributes_nil_hash
end

#declared_property_manager

def declared_property_manager
  @_declared_property_manager ||= DeclaredPropertyManager.new(self)
end

#inherited

def inherited(other)
  self.declared_property_manager.registered_properties.each_pair do |prop_key, prop_def|
    other.property(prop_key, prop_def.options)
  end
  super
end
#property

Defines a property on the class

See active_attr gem for allowed options, e.g which type Notice, in Neo4j you don’t have to declare properties before using them, see the neo4j-core api.

def property(name, options = {})
  prop = DeclaredProperty.new(name, options)
  prop.register
  declared_property_manager.register(prop)

  attribute(name, prop.options)
  constraint_or_index(name, options)
end

#undef_property

def undef_property(name)
  declared_property_manager.unregister(name)
  attribute_methods(name).each { |method| undef_method(method) }
  undef_constraint_or_index(name)
end