Module: Dragonfly::Configurable

Defined in:
lib/dragonfly/configurable.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods Classes: BadConfigAttribute, ConfigurationProxy, DeferredBlock

Class Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dragonfly/configurable.rb', line 7

def self.included(klass)
  klass.class_eval do
    include Configurable::InstanceMethods
    extend Configurable::ClassMethods

    # These aren't included in InstanceMethods because we need access to 'klass'
    # We can't just put them into InstanceMethods and use 'self.class' because
    # this won't always point to the class in which we've included Configurable,
    # e.g. if we've included it in an eigenclasse
    define_method :configuration_hash do
      @configuration_hash ||= klass.default_configuration.dup
    end
    private :configuration_hash

    define_method :configuration_methods do
      klass.configuration_methods
    end

  end
end