Method: ActForm::Attributes::ClassMethods#attribute
- Defined in:
- lib/act_form/attributes.rb
#attribute(name, cast_type = :object, **options) ⇒ Object Also known as: attr
attribute :name, type: :string
or
attribute :name, :string, required: true
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/act_form/attributes.rb', line 30 def attribute(name, cast_type = :object, **) name = name.to_s cast_type = [:type] || cast_type self.attribute_set = attribute_set.merge(name => [cast_type, ]) define_reader_method name, **.slice(:default) define_writer_method name, cast_type name end |