Module: CarrierWave::Grandcloud::ClassMethods

Defined in:
lib/carrierwave/grandcloud/configuration.rb

Instance Method Summary collapse

Instance Method Details

#add_config(name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/carrierwave/grandcloud/configuration.rb', line 15

def add_config(name)
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
    def self.#{name}(value=nil)
      @#{name} = value if value
      return @#{name} if self.object_id == #{self.object_id} || defined?(@#{name})
      name = superclass.#{name}
      return nil if name.nil? && !instance_variable_defined?("@#{name}")
      @#{name} = name && !name.is_a?(Module) && !name.is_a?(Symbol) && !name.is_a?(Numeric) && !name.is_a?(TrueClass) && !name.is_a?(FalseClass) ? name.dup : name
    end

    def self.#{name}=(value)
      @#{name} = value
    end

    def #{name}
      value = self.class.#{name}
      value.instance_of?(Proc) ? value.call : value
    end
  RUBY
end