Module: Interaction::Params

Defined in:
lib/interaction/params.rb

Overview

Uses Virtus for whitelisting and type coercion.

Virtus is configured in strict mode to ensure input is coerced to either the specified type or nil.

Examples:

class SignUpForm
  include Interaction::Params

  attribute :name, String
end

SignUpForm.new(name: 'John Smith').name
# => "John Smith"

SignUpForm.new(name: ['a']) # => Virtus::CoercionError

SignUpForm.new.name
# => nil

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



24
25
26
27
28
# File 'lib/interaction/params.rb', line 24

def self.included(base)
  base.class_eval do
    include Virtus.model(strict: true, required: false)
  end
end