Class: Anvil::Initializer
- Inherits:
-
Object
- Object
- Anvil::Initializer
- Defined in:
- lib/initializer.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(configuration) ⇒ Initializer
constructor
A new instance of Initializer.
- #load_application_view ⇒ Object
- #process ⇒ Object
- #require_controllers ⇒ Object
- #require_frameworks ⇒ Object
- #require_models ⇒ Object
- #set_load_paths ⇒ Object
Constructor Details
#initialize(configuration) ⇒ Initializer
Returns a new instance of Initializer.
14 15 16 |
# File 'lib/initializer.rb', line 14 def initialize(configuration) @configuration = configuration end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/initializer.rb', line 5 def configuration @configuration end |
Class Method Details
.run(command = :process, configuration = Configuration.new) {|configuration| ... } ⇒ Object
7 8 9 10 11 12 |
# File 'lib/initializer.rb', line 7 def self.run(command = :process, configuration = Configuration.new) yield configuration if block_given? initializer = new configuration initializer.send(command) initializer end |
Instance Method Details
#load_application_view ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/initializer.rb', line 42 def load_application_view application_file = File.join(configuration.view_path, 'application.rb') if File.exists?(application_file) eval(File.read(application_file)) else raise "Cannot find application view in: #{File.(application_file)}" end end |
#process ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/initializer.rb', line 18 def process set_load_paths require_frameworks require_controllers require_models load_application_view end |
#require_controllers ⇒ Object
36 37 |
# File 'lib/initializer.rb', line 36 def require_controllers end |
#require_frameworks ⇒ Object
32 33 34 |
# File 'lib/initializer.rb', line 32 def require_frameworks configuration.frameworks.each{|framework| require(framework.to_s)} end |
#require_models ⇒ Object
39 40 |
# File 'lib/initializer.rb', line 39 def require_models end |
#set_load_paths ⇒ Object
26 27 28 29 30 |
# File 'lib/initializer.rb', line 26 def set_load_paths load_paths = configuration.load_paths + configuration.framework_load_paths load_paths.reverse_each{|dir| $LOAD_PATH.unshift(dir) if File.directory?(dir)} $LOAD_PATH.uniq! end |