module Settings::InstanceLevel::ClassMethods
Will be bound to Object, provides support for defining settings structure + defaults at the class level for use in instances of that class. Defaults to database-backed dynamic storage with a 10 second reload. Requires that ActiveRecord be required prior to requiring this gem.
Public Instance Methods
instance_settings(options = {}, &block)
click to toggle source
# File lib/iron/settings/instance_level.rb, line 11 def instance_settings(options = {}, &block) unless @settings_instance_root @settings_instance_root = Settings::Root.new() @options = { :store => :dynamic }.merge(options) end # Set our default reload timing if options[:reload].nil? if options[:store] == :static # Static settings generally don't need reloading options[:reload] = false else # For dynamic, db-backed settings at the instance level, we use # a 10 second timeout by default options[:reload] = 10 end end # Save off our options @settings_instance_options = options # This class now need settings support at the instance level include InstanceMethods # Add our save hook if the class is an ActiveRecord model if defined?(ActiveRecord) && self < ActiveRecord::Base after_save :settings_save! end # Construct a builder and do the right thing builder = Settings::Builder.new(@settings_instance_root) builder.define(&block) if block builder end
settings_instance_options()
click to toggle source
# File lib/iron/settings/instance_level.rb, line 48 def settings_instance_options @settings_instance_options end
settings_instance_root()
click to toggle source
# File lib/iron/settings/instance_level.rb, line 52 def settings_instance_root @settings_instance_root end