Class: Voom::Presenters::App
Class Method Summary
collapse
[], container, list, registered?, registered_keys, reset!, resolve
#class_name, #snake_case, #sym_to_str
Class Method Details
.boot! ⇒ Object
10
11
12
13
14
15
|
# File 'lib/voom/presenters/app.rb', line 10
def boot!
logger.warn(no_roots_message) if presenter_paths.empty?
presenter_paths.each do |load_path|
Voom::Presenters::App.load('.', load_path) unless ENV['VOOM_ENV']=='testing'
end
end
|
.load(dir = 'app', root = ENV['VOOM_ROOT']||File.expand_path("../../../", __FILE__)) ⇒ Object
34
35
36
37
38
39
|
# File 'lib/voom/presenters/app.rb', line 34
def load(dir='app', root=ENV['VOOM_ROOT']||File.expand_path("../../../", __FILE__))
path = File.expand_path(dir, root)
trace {"Loading Presenters from: #{path}"}
Presenters::Registry.load(File.expand_path(dir, root))
Presenters::Registry.finalize
end
|
.no_roots_message ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/voom/presenters/app.rb', line 17
def no_roots_message
<<~MESSAGE
No root defined to load presenters!
Add the following to your initializer/boot process:
Voom::Presenters::Settings.configure do |config|
config.presenters.root = Rails.root.join('app')
end
MESSAGE
end
|
.register(name:, presenter: nil, &block) ⇒ Object
28
29
30
31
32
|
# File 'lib/voom/presenters/app.rb', line 28
def register(name:, presenter: nil, &block)
raise Errors::MissingArgument,
'A presenter class, proc, lambda or a block must be provided!' unless block_given? || presenter
container.register(sym_to_str(name), Voom::Presenters::ContainerItem.new(ui: block || presenter), {})
end
|