Module: ActiveDryDeps::StubContainer

Defined in:
lib/active_dry_deps/stub.rb

Instance Method Summary collapse

Instance Method Details

#reset(container) ⇒ Object



32
33
34
# File 'lib/active_dry_deps/stub.rb', line 32

def reset(container)
  replace(container)
end

#stub(key, value) ⇒ Object



28
29
30
# File 'lib/active_dry_deps/stub.rb', line 28

def stub(key, value)
  self[key] = value
end

#unstub(*unstub_keys, container:) ⇒ Object

Raises:

  • (ArgumentError)


36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/active_dry_deps/stub.rb', line 36

def unstub(*unstub_keys, container:)
  raise ArgumentError, "Аrguments must be a Array of Strings" if unstub_keys.empty?

  unstub_keys.each do |key|
    raise ArgumentError, "+#{key}+ must be a String" unless key.is_a?(String)

    if container.key?(key)
      self[key] = container[key]
    else
      delete(key)
    end
  end
end