Module: Trailblazer::Context::Container::CommonMethods
- Includes:
- Enumerable
- Included in:
- Trailblazer::Context::Container
- Defined in:
- lib/trailblazer/context/container.rb
Overview
Some common methods made available directly in Context::Container for performance tuning, extensions and to avoid ‘@replica` delegations.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object (also: #store)
- #delete(key) ⇒ Object
- #each(&block) ⇒ Object
- #fetch(key, default = nil, &block) ⇒ Object
- #key?(key) ⇒ Boolean
- #keys ⇒ Object
- #merge(other_hash) ⇒ Object
- #to_hash ⇒ Object
- #value?(value) ⇒ Boolean
- #values ⇒ Object
Instance Method Details
#[](key) ⇒ Object
42 43 44 |
# File 'lib/trailblazer/context/container.rb', line 42 def [](key) @replica[key] end |
#[]=(key, value) ⇒ Object Also known as: store
46 47 48 49 |
# File 'lib/trailblazer/context/container.rb', line 46 def []=(key, value) @replica[key] = value [key] = value end |
#delete(key) ⇒ Object
52 53 54 55 |
# File 'lib/trailblazer/context/container.rb', line 52 def delete(key) .delete(key) @replica.delete(key) end |
#each(&block) ⇒ Object
79 |
# File 'lib/trailblazer/context/container.rb', line 79 def each(&block); @replica.each(&block); end |
#fetch(key, default = nil, &block) ⇒ Object
65 66 67 |
# File 'lib/trailblazer/context/container.rb', line 65 def fetch(key, default = nil, &block) @replica.fetch(key, default, &block) end |
#key?(key) ⇒ Boolean
71 |
# File 'lib/trailblazer/context/container.rb', line 71 def key?(key); @replica.key?(key); end |
#keys ⇒ Object
69 |
# File 'lib/trailblazer/context/container.rb', line 69 def keys; @replica.keys; end |
#merge(other_hash) ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/trailblazer/context/container.rb', line 57 def merge(other_hash) self.class.new( , .merge(other_hash), replica_class: @replica_class, ) end |
#to_hash ⇒ Object
77 |
# File 'lib/trailblazer/context/container.rb', line 77 def to_hash; @replica.to_hash; end |
#value?(value) ⇒ Boolean
75 |
# File 'lib/trailblazer/context/container.rb', line 75 def value?(value); @replica.value?(value); end |
#values ⇒ Object
73 |
# File 'lib/trailblazer/context/container.rb', line 73 def values; @replica.values; end |