ClassMethods¶
Constants¶
Methods¶
#attribute!
+ show/hide codedef 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.
+ show/hide codedef attributes_nil_hash declared_property_manager.attributes_nil_hash end
#declared_property_manager
+ show/hide codedef declared_property_manager @_declared_property_manager ||= DeclaredPropertyManager.new(self) end
#default_properties
#default_properties_keys
+ show/hide codedef default_properties_keys @default_properties_keys ||= default_properties.keys end
- #default_property
TODO: Move this to the DeclaredPropertyManager
+ show/hide codedef default_property(name, &block) reset_default_properties(name) if default_properties.respond_to?(:size) default_properties[name] = block end
#default_property_values
+ show/hide codedef default_property_values(instance) default_properties.each_with_object({}) do |(key, block), result| result[key] = block.call(instance) end end
#inherited
+ show/hide codedef 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.
+ show/hide codedef 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
#reset_default_properties
+ show/hide codedef reset_default_properties(name_to_keep) default_properties.each_key do |property| @default_properties_keys = nil undef_method(property) unless property == name_to_keep end @default_properties_keys = nil @default_property = {} end
#undef_property
+ show/hide codedef undef_property(name) declared_property_manager.unregister(name) attribute_methods(name).each { |method| undef_method(method) } undef_constraint_or_index(name) end