Module: ActiveModel::Attributes::ClassMethods
| Relationships & Source Files | |
| Defined in: | activemodel/lib/active_model/attributes.rb |
Instance Method Summary
Instance Method Details
#attribute(name, type = Type::Value.new, **options)
[ GitHub ]# File 'activemodel/lib/active_model/attributes.rb', line 19
def attribute(name, type = Type::Value.new, **) name = name.to_s if type.is_a?(Symbol) type = ActiveModel::Type.lookup(type, **.except(:default)) end self.attribute_types = attribute_types.merge(name => type) define_default_attribute(name, .fetch(:default, NO_DEFAULT_PROVIDED), type) define_attribute_method(name) end