Class: Grape::Validations::OneofCollector
- Inherits:
-
Object
- Object
- Grape::Validations::OneofCollector
- Defined in:
- lib/grape/validations/oneof_collector.rb
Overview
Stand-in for the @api object that ParamsScope normally writes to. Used when evaluating a single variant block of a oneof: schema so that the variant’s validators are captured locally rather than registered on the real API. Exposes only the slice of the API surface that ParamsScope and its helpers touch during definition.
Instance Attribute Summary collapse
-
#inheritable_setting ⇒ Object
readonly
Returns the value of attribute inheritable_setting.
Class Method Summary collapse
-
.collect(variant_block) ⇒ Object
Evaluate
variant_blockin a freshParamsScopebacked by a new collector and return the validators that the block registered.
Instance Method Summary collapse
- #configuration ⇒ Object
- #declared_params ⇒ Object
-
#initialize ⇒ OneofCollector
constructor
A new instance of OneofCollector.
- #validators ⇒ Object
Constructor Details
#initialize ⇒ OneofCollector
Returns a new instance of OneofCollector.
13 14 15 16 |
# File 'lib/grape/validations/oneof_collector.rb', line 13 def initialize @inheritable_setting = Grape::Util::InheritableSetting.new @inheritable_setting.namespace_inheritable[:do_not_document] = true end |
Instance Attribute Details
#inheritable_setting ⇒ Object (readonly)
Returns the value of attribute inheritable_setting.
11 12 13 |
# File 'lib/grape/validations/oneof_collector.rb', line 11 def inheritable_setting @inheritable_setting end |
Class Method Details
.collect(variant_block) ⇒ Object
Evaluate variant_block in a fresh ParamsScope backed by a new collector and return the validators that the block registered.
32 33 34 35 36 |
# File 'lib/grape/validations/oneof_collector.rb', line 32 def self.collect(variant_block) collector = new ParamsScope.new(api: collector, type: Hash, &variant_block) collector.validators end |
Instance Method Details
#configuration ⇒ Object
18 19 20 |
# File 'lib/grape/validations/oneof_collector.rb', line 18 def configuration nil end |
#declared_params ⇒ Object
26 27 28 |
# File 'lib/grape/validations/oneof_collector.rb', line 26 def declared_params inheritable_setting.namespace_stackable[:declared_params] end |
#validators ⇒ Object
22 23 24 |
# File 'lib/grape/validations/oneof_collector.rb', line 22 def validators inheritable_setting.namespace_stackable[:validations] end |