Class: Bumbleworks::Configuration
- Inherits:
-
Object
- Object
- Bumbleworks::Configuration
- Defined in:
- lib/bumbleworks/configuration.rb
Overview
Stores configuration information
Configuration information is loaded from a configuration block defined within the client application.
Instance Attribute Summary collapse
-
#storage_adapters ⇒ Object
readonly
Returns the value of attribute storage_adapters.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_storage_adapter(adapter) ⇒ Object
Add a storage adapter to the set of possible adapters.
-
#clear! ⇒ Object
Clears all memoize variables and configuration settings.
-
#definitions_directory ⇒ Object
Path where Bumbleworks will look for ruote process defintiions to load.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #logger ⇒ Object
-
#participants_directory ⇒ Object
Path where Bumbleworks will look for ruote participants to load.
-
#root ⇒ Object
Root folder where Bumbleworks looks for ruote assets (participants, process_definitions, etc.) The root path must be absolute.
-
#tasks_directory ⇒ Object
Path where Bumbleworks will look for task modules to load.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
86 87 88 |
# File 'lib/bumbleworks/configuration.rb', line 86 def initialize @storage_adapters = [] end |
Instance Attribute Details
#storage_adapters ⇒ Object (readonly)
Returns the value of attribute storage_adapters.
15 16 17 |
# File 'lib/bumbleworks/configuration.rb', line 15 def storage_adapters @storage_adapters end |
Class Method Details
.define_setting(name) ⇒ Object
18 19 20 21 |
# File 'lib/bumbleworks/configuration.rb', line 18 def define_setting(name) defined_settings << name attr_accessor name end |
.defined_settings ⇒ Object
23 24 25 |
# File 'lib/bumbleworks/configuration.rb', line 23 def defined_settings @defined_settings ||= [] end |
Instance Method Details
#add_storage_adapter(adapter) ⇒ Object
Add a storage adapter to the set of possible adapters. Takes an object that responds to ‘driver`, `use?`, `storage_class`, and `display_name`.
140 141 142 143 144 145 146 |
# File 'lib/bumbleworks/configuration.rb', line 140 def add_storage_adapter(adapter) raise ArgumentError, "#{adapter} is not a Bumbleworks storage adapter" unless [:driver, :use?, :storage_class, :display_name].all? { |m| adapter.respond_to?(m) } @storage_adapters << adapter @storage_adapters end |
#clear! ⇒ Object
Clears all memoize variables and configuration settings
154 155 156 157 158 |
# File 'lib/bumbleworks/configuration.rb', line 154 def clear! defined_settings.each {|setting| instance_variable_set("@#{setting}", nil)} @storage_adapters = [] @definitions_folder = @participants_folder = @tasks_folder = nil end |
#definitions_directory ⇒ Object
Path where Bumbleworks will look for ruote process defintiions to load. The path can be relative or absolute. Relative paths are relative to Bumbleworks.root.
94 95 96 |
# File 'lib/bumbleworks/configuration.rb', line 94 def definitions_directory @definitions_folder ||= default_definition_directory end |
#logger ⇒ Object
148 149 150 |
# File 'lib/bumbleworks/configuration.rb', line 148 def logger @logger ||= Bumbleworks::SimpleLogger end |
#participants_directory ⇒ Object
Path where Bumbleworks will look for ruote participants to load. The path can be relative or absolute. Relative paths are relative to Bumbleworks.root.
102 103 104 |
# File 'lib/bumbleworks/configuration.rb', line 102 def participants_directory @participants_folder ||= default_participant_directory end |
#root ⇒ Object
Root folder where Bumbleworks looks for ruote assets (participants, process_definitions, etc.) The root path must be absolute. It can be defined through a configuration block:
Bumbleworks.configure { |c| c.root = '/somewhere' }
Or directly:
Bumbleworks.root = '/somewhere/else/'
If the root is not defined, Bumbleworks will use the root of known frameworks (Rails, Sinatra and Rory). Otherwise, it will raise an error if not defined.
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/bumbleworks/configuration.rb', line 126 def root @root ||= case when defined?(Rails) then Rails.root when defined?(Rory) then Rory.root when defined?(Padrino) then Padrino.root when defined?(Sinatra::Application) then Sinatra::Application.root end raise UndefinedSetting.new("Bumbleworks.root must be set") unless @root @root end |
#tasks_directory ⇒ Object
Path where Bumbleworks will look for task modules to load. The path can be relative or absolute. Relative paths are relative to Bumbleworks.root.
110 111 112 |
# File 'lib/bumbleworks/configuration.rb', line 110 def tasks_directory @tasks_folder ||= default_tasks_directory end |