class Extant::AttributeDefinition
Attributes
allow_nil[RW]
coercer_class[RW]
default_value[RW]
has_default[RW]
name[RW]
type[RW]
Public Class Methods
new(model, name, opts={})
click to toggle source
# File lib/extant/attribute_definition.rb, line 6 def initialize(model, name, opts={}) self.name = name self.type = opts[:type] self.has_default = opts.key?(:default) self.default_value = opts[:default] self.allow_nil = opts.fetch(:allow_nil, true) if type self.coercer_class = Extant::Coercers.find(type) end model.instance_eval do define_method name do extant_attributes[name].value end define_method "#{name}=" do |val| extant_attributes[name].value = val end end end