Module: SpecForge::Attribute::Resolvable
- Included in:
- SpecForge::Attribute, SpecForge::Attribute, ResolvableArray, ResolvableHash, ResolvableStruct
- Defined in:
- lib/spec_forge/attribute/resolvable.rb
Overview
Provides helper methods for resolving attributes
This module contains shared logic for handling attribute resolution in collection types. It defines procs that can be used with map and transform operations to recursively resolve nested attributes.
Instance Method Summary collapse
-
#resolve_as_matcher_proc ⇒ Proc
Returns a proc that resolves attributes into their matcher form.
-
#resolve_proc ⇒ Proc
Returns a proc that freshly resolves objects.
-
#resolved_proc ⇒ Proc
Returns a proc that resolves objects to their cached final values.
Instance Method Details
#resolve_as_matcher_proc ⇒ Proc
Returns a proc that resolves attributes into their matcher form. For objects that respond to #resolve_as_matcher, calls that method. For other objects, simply returns them unchanged.
57 58 59 |
# File 'lib/spec_forge/attribute/resolvable.rb', line 57 def resolve_as_matcher_proc ->(v) { v.respond_to?(:resolve_as_matcher) ? v.resolve_as_matcher : v } end |
#resolve_proc ⇒ Proc
Returns a proc that freshly resolves objects. For objects that respond to #resolve, calls that method. For other objects, simply returns them unchanged.
41 42 43 |
# File 'lib/spec_forge/attribute/resolvable.rb', line 41 def resolve_proc ->(v) { v.respond_to?(:resolve) ? v.resolve : v } end |
#resolved_proc ⇒ Proc
Returns a proc that resolves objects to their cached final values. For objects that respond to #resolved, calls that method. For other objects, simply returns them unchanged.
25 26 27 |
# File 'lib/spec_forge/attribute/resolvable.rb', line 25 def resolved_proc ->(v) { v.respond_to?(:resolved) ? v.resolved : v } end |