Class: RspecApiDocs::Resource::Example::DeepHashSet
- Inherits:
-
Object
- Object
- RspecApiDocs::Resource::Example::DeepHashSet
- Defined in:
- lib/rspec_api_docs/formatter/resource/example/deep_hash_set.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#keys ⇒ Object
readonly
Returns the value of attribute keys.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(hash, keys, value) ⇒ DeepHashSet
constructor
A new instance of DeepHashSet.
Constructor Details
#initialize(hash, keys, value) ⇒ DeepHashSet
Returns a new instance of DeepHashSet.
11 12 13 14 15 16 |
# File 'lib/rspec_api_docs/formatter/resource/example/deep_hash_set.rb', line 11 def initialize(hash, keys, value) @hash = hash @keys = keys @value = value @node = [] end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
5 6 7 |
# File 'lib/rspec_api_docs/formatter/resource/example/deep_hash_set.rb', line 5 def hash @hash end |
#keys ⇒ Object (readonly)
Returns the value of attribute keys.
5 6 7 |
# File 'lib/rspec_api_docs/formatter/resource/example/deep_hash_set.rb', line 5 def keys @keys end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
5 6 7 |
# File 'lib/rspec_api_docs/formatter/resource/example/deep_hash_set.rb', line 5 def value @value end |
Class Method Details
.call(*args) ⇒ Object
7 8 9 |
# File 'lib/rspec_api_docs/formatter/resource/example/deep_hash_set.rb', line 7 def self.call(*args) new(*args).call end |
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rspec_api_docs/formatter/resource/example/deep_hash_set.rb', line 18 def call keys.each_with_index do |key, index| case when key.nil? deep_set_value_at_array(index) break when index == keys.size - 1 set_value_at(key) else node << key end end hash end |