Module: Voom::ContainerMethods

Includes:
Symbol::ToStr
Included in:
Presenters::App
Defined in:
lib/voom/container_methods.rb

Instance Method Summary collapse

Methods included from Symbol::ToStr

#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

#containerObject



28
29
30
# File 'lib/voom/container_methods.rb', line 28

def container
  @container ||= Dry::Container.new
end

#listObject Also known as: keys



23
24
25
# File 'lib/voom/container_methods.rb', line 23

def list
  container.keys
end

#registered?(presenter) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/voom/container_methods.rb', line 11

def registered?(presenter)
  container.key?(sym_to_str(presenter))
end

#registered_keysObject



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