module ImageResizer::Configurable::InstanceMethods
Attributes
fallback_configurable[RW]
Public Instance Methods
config_methods()
click to toggle source
# File lib/image_resizer/configurable.rb, line 47 def config_methods @config_methods ||= self.class.config_methods.dup end
configuration()
click to toggle source
# File lib/image_resizer/configurable.rb, line 43 def configuration @configuration ||= {} end
configure() { |configuration_proxy| ... }
click to toggle source
# File lib/image_resizer/configurable.rb, line 27 def configure(&block) yield ConfigurationProxy.new(self) self end
configure_with(config, *args, &block)
click to toggle source
# File lib/image_resizer/configurable.rb, line 32 def configure_with(config, *args, &block) config = saved_config_for(config) if config.is_a?(Symbol) config.apply_configuration(self, *args) configure(&block) if block self end
default_configuration()
click to toggle source
# File lib/image_resizer/configurable.rb, line 51 def default_configuration @default_configuration ||= self.class.default_configuration.dup end
has_config_method?(method_name)
click to toggle source
# File lib/image_resizer/configurable.rb, line 39 def has_config_method?(method_name) config_methods.include?(method_name.to_sym) end
set_config_value(key, value)
click to toggle source
# File lib/image_resizer/configurable.rb, line 55 def set_config_value(key, value) configuration[key] = value child_configurables.each{|c| c.set_if_unset(key, value) } value end
use_as_fallback_config(other_configurable)
click to toggle source
# File lib/image_resizer/configurable.rb, line 61 def use_as_fallback_config(other_configurable) other_configurable.add_child_configurable(self) self.fallback_configurable = other_configurable end
Protected Instance Methods
add_child_configurable(obj)
click to toggle source
# File lib/image_resizer/configurable.rb, line 68 def add_child_configurable(obj) child_configurables << obj config_methods.push(*obj.config_methods) fallback_configurable.config_methods.push(*obj.config_methods) if fallback_configurable end
set_if_unset(key, value)
click to toggle source
# File lib/image_resizer/configurable.rb, line 74 def set_if_unset(key, value) set_config_value(key, value) unless set_locally?(key) end
Private Instance Methods
child_configurables()
click to toggle source
# File lib/image_resizer/configurable.rb, line 82 def child_configurables @child_configurables ||= [] end
default_value(key)
click to toggle source
# File lib/image_resizer/configurable.rb, line 90 def default_value(key) if default_configuration[key].is_a?(DeferredBlock) default_configuration[key] = default_configuration[key].call end default_configuration[key] end
saved_config_for(symbol)
click to toggle source
# File lib/image_resizer/configurable.rb, line 101 def saved_config_for(symbol) config = saved_configs[symbol] if config.nil? raise ArgumentError, "#{symbol.inspect} is not a known configuration - try one of #{saved_configs.keys.join(', ')}" end config = config.call if config.respond_to?(:call) config end
saved_configs()
click to toggle source
# File lib/image_resizer/configurable.rb, line 97 def saved_configs self.class.saved_configs end
set_locally?(key)
click to toggle source
# File lib/image_resizer/configurable.rb, line 86 def set_locally?(key) instance_variable_defined?("@#{key}") end