class Stringex::Configuration::Base
def self.configure(&block)
def self.configure(&block) configurator = Stringex::Configuration::Configurator.new(self) yield configurator end
def self.system_wide_customizations
def self.system_wide_customizations @system_wide_customizations ||= {} end
def self.unconfigure!
def self.unconfigure! @system_wide_customizations = {} end
def self.valid_configuration_details
def self.valid_configuration_details default_settings.keys end
def adapter
NOTE: This does not cache itself so that instance and class can be cached on the adapter
def adapter adapter_name = settings.adapter || Stringex::ActsAsUrl::Adapter.first_available case adapter_name when Class adapter_name.send :new, self when :active_record Stringex::ActsAsUrl::Adapter::ActiveRecord.new self when :mongoid Stringex::ActsAsUrl::Adapter::Mongoid.new self else raise ArgumentError, "#{adapter_name} is not a defined ActsAsUrl adapter. Please feel free to implement your own and submit it back upstream." end end
def default_settings
def default_settings raise ArgumentError, "You shouldn't have hit default_settings on Stringex::Configuration::Base. Check your code." end
def initialize(local_options = {})
def initialize(local_options = {}) current_settings = default_settings.merge(system_wide_customizations) current_settings.merge! local_options @settings = OpenStruct.new(current_settings) end
def system_wide_customizations
def system_wide_customizations self.class.system_wide_customizations end