Class: RSpec::JsonMatchers::Utils::KeyPath::Extraction::ExtractionWithOnePathPart Private
- Inherits:
-
Object
- Object
- RSpec::JsonMatchers::Utils::KeyPath::Extraction::ExtractionWithOnePathPart
- Defined in:
- lib/rspec/json_matchers/utils/key_path/extraction.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Internal implementation for an extraction operation with only one part of the path
Instance Method Summary collapse
-
#extract ⇒ Extraction::Result
private
Actually perform the extraction and return the result Since the object could be falsy, an object of custom class is returned instead of the object only.
-
#initialize(object, path_part) ⇒ ExtractionWithOnePathPart
constructor
private
Create a new extractor with the “source object” and the path to be used for extracting our target object.
Constructor Details
#initialize(object, path_part) ⇒ ExtractionWithOnePathPart
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new extractor with the “source object” and the path to be used for extracting our target object
80 81 82 83 |
# File 'lib/rspec/json_matchers/utils/key_path/extraction.rb', line 80 def initialize(object, path_part) @object = object @path_part = path_part end |
Instance Method Details
#extract ⇒ Extraction::Result
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Actually perform the extraction and return the result Since the object could be falsy, an object of custom class is returned instead of the object only
90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/rspec/json_matchers/utils/key_path/extraction.rb', line 90 def extract case object when Hash extract_object_from_hash when Array extract_object_from_array else # Disallow non JSON collection type Result.new(object, false) end end |