Class: Reactive::Configuration
- Inherits:
-
Object
- Object
- Reactive::Configuration
- Defined in:
- lib/initializer.rb
Instance Attribute Summary collapse
-
#action_mailer ⇒ Object
A stub for setting options on ActionMailer::Base.
-
#active_record ⇒ Object
A stub for setting options on ActiveRecord::Base.
-
#active_resource ⇒ Object
A stub for setting options on ActiveRecord::Base.
-
#asset_path ⇒ Object
Returns the value of attribute asset_path.
-
#cache_classes ⇒ Object
Whether or not classes should be cached (set to false if you want application classes to be reloaded on each event).
-
#controller ⇒ Object
A stub for setting options on Reactive::Controller::Base.
-
#controller_path ⇒ Object
Some paths.
-
#database_configuration_file ⇒ Object
The path to the database configuration file to use.
-
#frameworks ⇒ Object
The list of framework components that should be loaded.
-
#load_once_paths ⇒ Object
An array of paths from which Reactive will automatically load from only once.
-
#load_paths ⇒ Object
An array of additional paths to prepend to the load path.
-
#log_level ⇒ Object
The log level to use for the default Reactive logger.
-
#log_path ⇒ Object
The path to the log file to use.
-
#logger ⇒ Object
The specific logger to use.
-
#model_path ⇒ Object
Returns the value of attribute model_path.
-
#root_path ⇒ Object
readonly
The application’s base directory.
-
#view ⇒ Object
A stub for setting options on Reactive::View::Base.
-
#view_path ⇒ Object
Returns the value of attribute view_path.
-
#view_provider ⇒ Object
The view provider name.
Instance Method Summary collapse
-
#after_initialize(&after_initialize_block) ⇒ Object
Adds a block which will be executed after rails has been fully initialized.
-
#after_initialize_blocks ⇒ Object
Returns the blocks added with Configuration#after_initialize.
-
#database_configuration ⇒ Object
Loads and returns the contents of the #database_configuration_file.
-
#environment ⇒ Object
Return the currently selected environment.
-
#environment_path ⇒ Object
The path to the current environment’s file (development.rb, etc.).
- #framework_paths ⇒ Object
-
#global_environment_path ⇒ Object
The path to the global environment’s file.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #set_root_path! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
# File 'lib/initializer.rb', line 293 def initialize set_root_path! self.frameworks = default_frameworks self.load_paths = default_load_paths self.load_once_paths = [] self.log_path = default_log_path self.log_level = default_log_level self.view_path = default_view_path self.controller_path = default_controller_path self.model_path = default_model_path self.asset_path = default_asset_path self.database_configuration_file = default_database_configuration_file self.cache_classes = default_cache_classes for framework in default_frameworks self.send("#{framework}=", OrderedOptions.new) end end |
Instance Attribute Details
#action_mailer ⇒ Object
A stub for setting options on ActionMailer::Base
239 240 241 |
# File 'lib/initializer.rb', line 239 def action_mailer @action_mailer end |
#active_record ⇒ Object
A stub for setting options on ActiveRecord::Base
242 243 244 |
# File 'lib/initializer.rb', line 242 def active_record @active_record end |
#active_resource ⇒ Object
A stub for setting options on ActiveRecord::Base
245 246 247 |
# File 'lib/initializer.rb', line 245 def active_resource @active_resource end |
#asset_path ⇒ Object
Returns the value of attribute asset_path.
290 291 292 |
# File 'lib/initializer.rb', line 290 def asset_path @asset_path end |
#cache_classes ⇒ Object
Whether or not classes should be cached (set to false if you want application classes to be reloaded on each event)
249 250 251 |
# File 'lib/initializer.rb', line 249 def cache_classes @cache_classes end |
#controller ⇒ Object
A stub for setting options on Reactive::Controller::Base
233 234 235 |
# File 'lib/initializer.rb', line 233 def controller @controller end |
#controller_path ⇒ Object
Some paths
287 288 289 |
# File 'lib/initializer.rb', line 287 def controller_path @controller_path end |
#database_configuration_file ⇒ Object
The path to the database configuration file to use. (Defaults to config/database.yml.)
256 257 258 |
# File 'lib/initializer.rb', line 256 def database_configuration_file @database_configuration_file end |
#frameworks ⇒ Object
The list of framework components that should be loaded. (Defaults to :active_record, :action_mailer, and :active_resource).
261 262 263 |
# File 'lib/initializer.rb', line 261 def frameworks @frameworks end |
#load_once_paths ⇒ Object
An array of paths from which Reactive will automatically load from only once. All elements of this array must also be in load_paths.
269 270 271 |
# File 'lib/initializer.rb', line 269 def load_once_paths @load_once_paths end |
#load_paths ⇒ Object
An array of additional paths to prepend to the load path. By default, all app, lib, vendor and mock paths are included in this list.
265 266 267 |
# File 'lib/initializer.rb', line 265 def load_paths @load_paths end |
#log_level ⇒ Object
The log level to use for the default Reactive logger. In production mode, this defaults to :info. In development mode, it defaults to :debug.
274 275 276 |
# File 'lib/initializer.rb', line 274 def log_level @log_level end |
#log_path ⇒ Object
The path to the log file to use. Defaults to log/##environment.log (e.g. log/development.log or log/production.log).
278 279 280 |
# File 'lib/initializer.rb', line 278 def log_path @log_path end |
#logger ⇒ Object
The specific logger to use. By default, a logger will be created and initialized using #log_path and #log_level, but a programmer may specifically set the logger to use via this accessor and it will be used directly.
284 285 286 |
# File 'lib/initializer.rb', line 284 def logger @logger end |
#model_path ⇒ Object
Returns the value of attribute model_path.
288 289 290 |
# File 'lib/initializer.rb', line 288 def model_path @model_path end |
#root_path ⇒ Object (readonly)
The application’s base directory.
230 231 232 |
# File 'lib/initializer.rb', line 230 def root_path @root_path end |
#view ⇒ Object
A stub for setting options on Reactive::View::Base
236 237 238 |
# File 'lib/initializer.rb', line 236 def view @view end |
#view_path ⇒ Object
Returns the value of attribute view_path.
289 290 291 |
# File 'lib/initializer.rb', line 289 def view_path @view_path end |
#view_provider ⇒ Object
The view provider name
252 253 254 |
# File 'lib/initializer.rb', line 252 def view_provider @view_provider end |
Instance Method Details
#after_initialize(&after_initialize_block) ⇒ Object
Adds a block which will be executed after rails has been fully initialized. Useful for per-environment configuration which depends on the framework being fully initialized.
343 344 345 |
# File 'lib/initializer.rb', line 343 def after_initialize(&after_initialize_block) after_initialize_blocks << after_initialize_block if after_initialize_block end |
#after_initialize_blocks ⇒ Object
Returns the blocks added with Configuration#after_initialize
348 349 350 |
# File 'lib/initializer.rb', line 348 def after_initialize_blocks @after_initialize_blocks ||= [] end |
#database_configuration ⇒ Object
Loads and returns the contents of the #database_configuration_file.
318 319 320 |
# File 'lib/initializer.rb', line 318 def database_configuration YAML::load(IO.read(database_configuration_file)) end |
#environment ⇒ Object
Return the currently selected environment. By default, it returns the value of the REACTIVE_ENV constant.
336 337 338 |
# File 'lib/initializer.rb', line 336 def environment ::REACTIVE_ENV end |
#environment_path ⇒ Object
The path to the current environment’s file (development.rb, etc.). By default the file is at config/environments/#{environment}.rb.
324 325 326 |
# File 'lib/initializer.rb', line 324 def environment_path "#{root_path}/config/environments/#{environment}.rb" end |
#framework_paths ⇒ Object
352 353 354 355 356 357 358 359 360 361 |
# File 'lib/initializer.rb', line 352 def framework_paths paths = %w(activesupport/lib) # TODO: Add the provider path here [:active_record, :action_mailer, :active_resource, :action_web_service].each do |framework| paths << "#{framework.to_s.gsub('_', '')}/lib" if frameworks.include? framework end paths.select { |dir| File.directory?(dir) } end |
#global_environment_path ⇒ Object
The path to the global environment’s file. By default the file is at config/environment.rb.
330 331 332 |
# File 'lib/initializer.rb', line 330 def global_environment_path "#{root_path}/config/environment.rb" end |
#set_root_path! ⇒ Object
313 314 315 |
# File 'lib/initializer.rb', line 313 def set_root_path! @root_path = File.(::REACTIVE_ROOT) end |