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_properties.attributes_nil_hash
end

#build_property

def build_property(name, options)
  prop = DeclaredProperty.new(name, options)
  prop.register
  declared_properties.register(prop)
  yield prop
  constraint_or_index(name, options)
end

#declared_properties

def declared_properties
  @_declared_properties ||= DeclaredProperties.new(self)
end

#inherit_property

def inherit_property(name, active_attr, options = {})
  build_property(name, options) do |prop|
    attributes[prop.name.to_s] = active_attr
  end
end

#inherited

def inherited(other)
  self.declared_properties.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 = {})
  build_property(name, options) do |prop|
    attribute(name, prop.options)
  end
end

#undef_property

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