Class: RSchema::Schemas::Set
- Inherits:
-
Object
- Object
- RSchema::Schemas::Set
- Defined in:
- lib/rschema/schemas/set.rb
Overview
A schema that matches ‘Set` objects (from the Ruby standard library)
Instance Attribute Summary collapse
-
#subschema ⇒ Object
readonly
Returns the value of attribute subschema.
Instance Method Summary collapse
- #call(value, options) ⇒ Object
-
#initialize(subschema) ⇒ Set
constructor
A new instance of Set.
- #with_wrapped_subschemas(wrapper) ⇒ Object
Constructor Details
#initialize(subschema) ⇒ Set
Returns a new instance of Set.
19 20 21 |
# File 'lib/rschema/schemas/set.rb', line 19 def initialize(subschema) @subschema = subschema end |
Instance Attribute Details
#subschema ⇒ Object (readonly)
Returns the value of attribute subschema.
17 18 19 |
# File 'lib/rschema/schemas/set.rb', line 17 def subschema @subschema end |
Instance Method Details
#call(value, options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rschema/schemas/set.rb', line 23 def call(value, ) return not_a_set_result(value) unless value.is_a?(::Set) validated_set, errors = apply_subschema(value, ) if errors.empty? Result.success(validated_set) else Result.failure(errors) end end |
#with_wrapped_subschemas(wrapper) ⇒ Object
35 36 37 38 |
# File 'lib/rschema/schemas/set.rb', line 35 def with_wrapped_subschemas(wrapper) wrapped_subschema = wrapper.wrap(subschema) self.class.new(wrapped_subschema) end |