Module: StructuredParams::AttributeMethods

Extended by:
ActiveSupport::Concern
Included in:
Params
Defined in:
lib/structured_params/attribute_methods.rb

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)