ClassMethods¶
Constants¶
Methods¶
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
def build_property(name, options) prop = DeclaredProperty.new(name, options) prop.register declared_properties.register(prop) yield prop constraint_or_index(name, options) end
def declared_properties @_declared_properties ||= DeclaredProperties.new(self) end
def inherit_property(name, active_attr, options = {}) build_property(name, options) do |prop| attributes[prop.name.to_s] = active_attr end end
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
def undef_property(name) declared_properties.unregister(name) attribute_methods(name).each { |method| undef_method(method) } undef_constraint_or_index(name) end