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.
-
#entity_classes ⇒ Object
Default entity_classes to empty array.
- #error_handlers ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #logger ⇒ Object
- #observers ⇒ Object
-
#participant_registration_file ⇒ Object
Path where Bumbleworks will look for the participant registration file.
-
#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.
-
#storage_adapter ⇒ Object
If storage_adapter is not explicitly set, find first registered adapter that can use Bumbleworks.storage.
-
#store_history ⇒ Object
Default history storage to true.
-
#tasks_directory ⇒ Object
Path where Bumbleworks will look for task modules to load.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
179 180 181 182 183 184 |
# File 'lib/bumbleworks/configuration.rb', line 179 def initialize @storage_adapters = [] @storage_options = {} @cached_paths = {} @timeout ||= 5 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`.
263 264 265 266 267 268 269 |
# File 'lib/bumbleworks/configuration.rb', line 263 def add_storage_adapter(adapter) raise ArgumentError, "#{adapter} is not a Bumbleworks storage adapter" unless [:driver, :use?, :new_storage, :allow_history_storage?, :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
296 297 298 299 300 |
# File 'lib/bumbleworks/configuration.rb', line 296 def clear! defined_settings.each {|setting| instance_variable_set("@#{setting}", nil)} @storage_adapters = [] @cached_paths = {} 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.
190 191 192 193 194 195 |
# File 'lib/bumbleworks/configuration.rb', line 190 def definitions_directory @cached_paths[:definitions_directory] ||= look_up_configured_path( :definitions_directory, :defaults => ['process_definitions', 'processes'] ) end |
#entity_classes ⇒ Object
Default entity_classes to empty array
237 238 239 |
# File 'lib/bumbleworks/configuration.rb', line 237 def entity_classes @entity_classes ||= [] end |
#error_handlers ⇒ Object
302 303 304 |
# File 'lib/bumbleworks/configuration.rb', line 302 def error_handlers @error_handlers ||= [Bumbleworks::ErrorLogger] end |
#logger ⇒ Object
286 287 288 |
# File 'lib/bumbleworks/configuration.rb', line 286 def logger @logger ||= Bumbleworks::SimpleLogger end |
#observers ⇒ Object
290 291 292 |
# File 'lib/bumbleworks/configuration.rb', line 290 def observers @observers ||= [] end |
#participant_registration_file ⇒ Object
Path where Bumbleworks will look for the participant registration file. The path can be relative or absolute. Relative paths are relative to Bumbleworks.root.
223 224 225 226 227 228 229 |
# File 'lib/bumbleworks/configuration.rb', line 223 def participant_registration_file @cached_paths[:participant_registration_file] ||= look_up_configured_path( :participant_registration_file, :defaults => ['participants.rb'], :file => true ) 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.
201 202 203 204 205 206 |
# File 'lib/bumbleworks/configuration.rb', line 201 def participants_directory look_up_configured_path( :participants_directory, :defaults => ['participants'] ) 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), appending “lib/bumbleworks”. Otherwise, it will raise an error if not defined.
253 254 255 256 257 258 |
# File 'lib/bumbleworks/configuration.rb', line 253 def root @root ||= begin raise UndefinedSetting.new("Bumbleworks.root must be set") unless framework_root File.join(framework_root, "lib", "bumbleworks") end end |
#storage_adapter ⇒ Object
If storage_adapter is not explicitly set, find first registered adapter that can use Bumbleworks.storage.
274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/bumbleworks/configuration.rb', line 274 def storage_adapter @storage_adapter ||= begin all_adapters = storage_adapters raise UndefinedSetting, "No storage adapters configured" if all_adapters.empty? adapter = all_adapters.detect do |potential_adapter| potential_adapter.use?(storage) end raise UndefinedSetting, "Storage is missing or not supported. Supported: #{all_adapters.map(&:display_name).join(', ')}" unless adapter adapter end end |
#store_history ⇒ Object
Default history storage to true
232 233 234 |
# File 'lib/bumbleworks/configuration.rb', line 232 def store_history @store_history.nil? ? true : @store_history 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.
212 213 214 215 216 217 |
# File 'lib/bumbleworks/configuration.rb', line 212 def tasks_directory @cached_paths[:tasks_directory] ||= look_up_configured_path( :tasks_directory, :defaults => ['tasks'] ) end |