Class: ActionSpec::Schema::Resolver
- Inherits:
-
Object
- Object
- ActionSpec::Schema::Resolver
- Defined in:
- lib/action_spec/schema/resolver.rb
Instance Method Summary collapse
-
#initialize(field:, source:, context:, coerce:, result:, path:) ⇒ Resolver
constructor
A new instance of Resolver.
- #resolve ⇒ Object
Constructor Details
#initialize(field:, source:, context:, coerce:, result:, path:) ⇒ Resolver
Returns a new instance of Resolver.
6 7 8 9 10 11 12 13 |
# File 'lib/action_spec/schema/resolver.rb', line 6 def initialize(field:, source:, context:, coerce:, result:, path:) @field = field @source = source @context = context @coerce = coerce @result = result @path = [*path, field.name] end |
Instance Method Details
#resolve ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/action_spec/schema/resolver.rb', line 15 def resolve return resolve_missing unless present? return resolve_nil if value.nil? return finalize(schema.blank_value(value)) if blank_string_allowed? return resolve_blank if blank_disallowed? finalize(schema.cast(value, context:, coerce:, result:, path:, field:)) end |