class Stringex::Configuration::Base
Attributes
Public Class Methods
Source
# File lib/stringex/configuration/base.rb 29 def self.configure(&block) 30 configurator = Stringex::Configuration::Configurator.new(self) 31 yield configurator 32 end
Source
# File lib/stringex/configuration/base.rb 6 def initialize(local_options = {}) 7 current_settings = default_settings.merge(system_wide_customizations) 8 current_settings.merge! local_options 9 10 @settings = OpenStruct.new(current_settings) 11 end
Source
# File lib/stringex/configuration/base.rb 34 def self.system_wide_customizations 35 @system_wide_customizations ||= {} 36 end
Source
# File lib/stringex/configuration/base.rb 38 def self.unconfigure! 39 @system_wide_customizations = {} 40 end
Source
# File lib/stringex/configuration/base.rb 52 def self.valid_configuration_details 53 default_settings.keys 54 end
Public Instance Methods
Source
# File lib/stringex/configuration/base.rb 15 def adapter 16 adapter_name = settings.adapter || Stringex::ActsAsUrl::Adapter.first_available 17 case adapter_name 18 when Class 19 adapter_name.send :new, self 20 when :active_record 21 Stringex::ActsAsUrl::Adapter::ActiveRecord.new self 22 when :mongoid 23 Stringex::ActsAsUrl::Adapter::Mongoid.new self 24 else 25 raise ArgumentError, "#{adapter_name} is not a defined ActsAsUrl adapter. Please feel free to implement your own and submit it back upstream." 26 end 27 end
NOTE: This does not cache itself so that instance and class can be cached on the adapter without worrying about thread safety or race conditions
Private Instance Methods
Source
# File lib/stringex/configuration/base.rb 44 def default_settings 45 raise ArgumentError, "You shouldn't have hit default_settings on Stringex::Configuration::Base. Check your code." 46 end
Source
# File lib/stringex/configuration/base.rb 48 def system_wide_customizations 49 self.class.system_wide_customizations 50 end