Module: StructuredParams::AttributeMethods
- Extended by:
- ActiveSupport::Concern
- Included in:
- Params
- Defined in:
- lib/structured_params/attribute_methods.rb,
sig/structured_params/attribute_methods.rbs
Overview
Extends ActiveModel::Attributes to define attr_before_type_cast accessors
for each attribute, mirroring ActiveRecord::AttributeMethods::BeforeTypeCast.
Example:
class UserParams < StructuredParams::Params
attribute :age, :integer
end
params = UserParams.new(age: "42abc")
params.age # => 42 (type-cast)
params.age_before_type_cast # => "42abc" (raw input)
Class Method Summary collapse
-
.attribute ⇒ void
Override attribute to also define
attr_before_type_castvia ActiveModel::Attribute#value_before_type_cast : (Symbol name, *untyped) -> void.
Class Method Details
.attribute ⇒ void
This method returns an undefined value.
Override attribute to also define attr_before_type_cast
via ActiveModel::Attribute#value_before_type_cast
: (Symbol name, *untyped) -> void
21 |
# File 'sig/structured_params/attribute_methods.rbs', line 21
def self.attribute: (Symbol name, *untyped) -> void
|