Class: Grape::Validations::SharedOptions

Inherits:
Data
  • Object
show all
Defined in:
lib/grape/validations/shared_options.rb

Overview

Immutable value object holding the two options every validator reads at construction time: allow_blank and fail_fast. Internal to Validators::Base, which builds it from the opts Hash so the public 5th-argument contract stays a plain Hash — not part of any wire contract.

Defaults mirror the prior opts.values_at behaviour: allow_blank is nil when the declaration didn’t supply it (validators treat nil as “not set”), fail_fast defaults to false.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_blank: nil, fail_fast: false) ⇒ SharedOptions

Returns a new instance of SharedOptions.



14
15
16
# File 'lib/grape/validations/shared_options.rb', line 14

def initialize(allow_blank: nil, fail_fast: false)
  super
end

Instance Attribute Details

#allow_blankObject (readonly)

Returns the value of attribute allow_blank

Returns:

  • (Object)

    the current value of allow_blank



13
14
15
# File 'lib/grape/validations/shared_options.rb', line 13

def allow_blank
  @allow_blank
end

#fail_fastObject (readonly)

Returns the value of attribute fail_fast

Returns:

  • (Object)

    the current value of fail_fast



13
14
15
# File 'lib/grape/validations/shared_options.rb', line 13

def fail_fast
  @fail_fast
end