Module: Voom::ContainerMethods
Instance Method Summary
collapse
#class_name, #snake_case, #sym_to_str
Instance Method Details
#[](name) ⇒ Object
15
16
17
|
# File 'lib/voom/container_methods.rb', line 15
def [](name)
resolve(name)
end
|
#container ⇒ Object
28
29
30
|
# File 'lib/voom/container_methods.rb', line 28
def container
@container ||= Dry::Container.new
end
|
#list ⇒ Object
Also known as:
keys
23
24
25
|
# File 'lib/voom/container_methods.rb', line 23
def list
container.keys
end
|
#registered?(presenter) ⇒ Boolean
11
12
13
|
# File 'lib/voom/container_methods.rb', line 11
def registered?(presenter)
container.key?(sym_to_str(presenter))
end
|
#registered_keys ⇒ Object
7
8
9
|
# File 'lib/voom/container_methods.rb', line 7
def registered_keys
@registered_keys ||= []
end
|
#reset! ⇒ Object
This method empties out the container It should ONLY be used for testing purposes
34
35
36
37
38
|
# File 'lib/voom/container_methods.rb', line 34
def reset!
registered_keys.each { |key| ClassConstants.new(key).deconstantize }
@registered_keys = []
container._container.clear
end
|
#resolve(name) ⇒ Object
19
20
21
|
# File 'lib/voom/container_methods.rb', line 19
def resolve(name)
container.resolve(sym_to_str(name))
end
|