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

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
  @mutable_options[key] = value
end

#delete(key) ⇒ Object


52
53
54
55
# File 'lib/trailblazer/context/container.rb', line 52

def delete(key)
  @replica.delete(key)
  @mutable_options.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

Returns:

  • (Boolean)

71
# File 'lib/trailblazer/context/container.rb', line 71

def key?(key); @replica.key?(key); end

#keysObject


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(
    @wrapped_options,
    @mutable_options.merge(other_hash),
    replica_class: @replica_class,
  )
end

#to_hashObject


77
# File 'lib/trailblazer/context/container.rb', line 77

def to_hash; @replica.to_hash; end

#value?(value) ⇒ Boolean

Returns:

  • (Boolean)

75
# File 'lib/trailblazer/context/container.rb', line 75

def value?(value); @replica.value?(value); end

#valuesObject


73
# File 'lib/trailblazer/context/container.rb', line 73

def values; @replica.values; end