Module: Dragonfly::Configurable::InstanceMethods

Defined in:
lib/dragonfly/configurable.rb

Instance Method Summary collapse

Instance Method Details

#config_methodsObject


47
48
49
# File 'lib/dragonfly/configurable.rb', line 47

def config_methods
  @config_methods ||= self.class.config_methods.dup
end

#configurationObject


43
44
45
# File 'lib/dragonfly/configurable.rb', line 43

def configuration
  @configuration ||= {}
end

#configure {|ConfigurationProxy.new(self)| ... } ⇒ Object

Yields:


27
28
29
30
# File 'lib/dragonfly/configurable.rb', line 27

def configure(&block)
  yield ConfigurationProxy.new(self)
  self
end

#configure_with(config, *args, &block) ⇒ Object


32
33
34
35
36
37
# File 'lib/dragonfly/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_configurationObject


51
52
53
# File 'lib/dragonfly/configurable.rb', line 51

def default_configuration
  @default_configuration ||= self.class.default_configuration.dup
end

#has_config_method?(method_name) ⇒ Boolean

Returns:

  • (Boolean)

39
40
41
# File 'lib/dragonfly/configurable.rb', line 39

def has_config_method?(method_name)
  config_methods.include?(method_name.to_sym)
end

#set_config_value(key, value) ⇒ Object


55
56
57
58
59
# File 'lib/dragonfly/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) ⇒ Object


61
62
63
64
# File 'lib/dragonfly/configurable.rb', line 61

def use_as_fallback_config(other_configurable)
  other_configurable.add_child_configurable(self)
  self.fallback_configurable = other_configurable
end