Class: Atelier::Application
- Inherits:
-
Object
- Object
- Atelier::Application
- Includes:
- Singleton
- Defined in:
- lib/atelier/application.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#root_library ⇒ Object
readonly
Returns the value of attribute root_library.
Instance Method Summary collapse
-
#initialize ⇒ Application
constructor
A new instance of Application.
- #load_root_library(name, &block) ⇒ Object
- #run(library_file, action, *parameters) ⇒ Object
- #send_action(action, *parameters) ⇒ Object
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
14 15 16 17 18 19 20 21 22 |
# File 'lib/atelier/application.rb', line 14 def initialize @root_library = nil @logger = Logger.new(STDERR) @logger.level = Logger::WARN Kernel.send(:define_method, :library) do |name, &block| Application.instance.load_root_library(name, &block) end end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
12 13 14 |
# File 'lib/atelier/application.rb', line 12 def logger @logger end |
#root_library ⇒ Object (readonly)
Returns the value of attribute root_library.
12 13 14 |
# File 'lib/atelier/application.rb', line 12 def root_library @root_library end |
Instance Method Details
#load_root_library(name, &block) ⇒ Object
24 25 26 |
# File 'lib/atelier/application.rb', line 24 def load_root_library(name, &block) @root_library = Library.new(name, &block) end |
#run(library_file, action, *parameters) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/atelier/application.rb', line 34 def run(library_file, action, *parameters) load(library_file) send_action(action, *parameters) rescue Exception => e logger.error e end |
#send_action(action, *parameters) ⇒ Object
28 29 30 31 32 |
# File 'lib/atelier/application.rb', line 28 def send_action(action, *parameters) root_library.send(action, *parameters) rescue Exception => e logger.error e end |