Class: SpecForge::Attribute::ResolvableStruct
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SpecForge::Attribute::ResolvableStruct
- Includes:
- Resolvable
- Defined in:
- lib/spec_forge/attribute/resolvable_struct.rb
Overview
Wraps struct-like objects (Struct, Data, OpenStruct) to make them resolvable
Provides resolution capabilities for struct-like objects, allowing their values to be resolved recursively while maintaining the original struct type.
Instance Method Summary collapse
-
#resolve ⇒ Struct, ...
Returns the struct with all values resolved (not cached).
-
#resolve_as_matcher ⇒ RSpec::Matchers::BuiltIn::BaseMatcher
Converts the struct's values into RSpec matchers.
-
#resolved ⇒ Struct, ...
Returns the struct with all values fully resolved and cached.
-
#value ⇒ Struct, ...
Returns the wrapped struct object.
Methods included from Resolvable
#resolve_as_matcher_proc, #resolve_proc, #resolved_proc
Instance Method Details
#resolve ⇒ Struct, ...
Returns the struct with all values resolved (not cached)
38 39 40 41 |
# File 'lib/spec_forge/attribute/resolvable_struct.rb', line 38 def resolve hash = value.to_h.transform_values(&resolve_proc) to_structlike(hash) end |
#resolve_as_matcher ⇒ RSpec::Matchers::BuiltIn::BaseMatcher
Converts the struct's values into RSpec matchers
48 49 50 51 |
# File 'lib/spec_forge/attribute/resolvable_struct.rb', line 48 def resolve_as_matcher result = value.to_h.transform_values(&resolve_as_matcher_proc) Attribute::Literal.new(result).resolve_as_matcher end |
#resolved ⇒ Struct, ...
Returns the struct with all values fully resolved and cached
28 29 30 31 |
# File 'lib/spec_forge/attribute/resolvable_struct.rb', line 28 def resolved hash = value.to_h.transform_values(&resolved_proc) to_structlike(hash) end |
#value ⇒ Struct, ...
Returns the wrapped struct object
19 20 21 |
# File 'lib/spec_forge/attribute/resolvable_struct.rb', line 19 def value __getobj__ end |