Module: DirectWave::Uploader::Configuration::ClassMethods

Defined in:
lib/directwave/uploader/configuration.rb

Instance Method Summary collapse

Instance Method Details

#add_config(name) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/directwave/uploader/configuration.rb', line 28

def add_config(name)
  class_eval <<-RUBY, __FILE__, __LINE__ + 1
    class << self
      def #{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 #{name}=(value)
        @#{name} = value
      end
    end

    def #{name}
      self.class.#{name}
    end
  RUBY
end

#configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



50
51
52
# File 'lib/directwave/uploader/configuration.rb', line 50

def configure
  yield self
end

#reset_configObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/directwave/uploader/configuration.rb', line 54

def reset_config
  configure do |config|
    config.s3_access_policy = :public_read
    config.s3_region        = "us-east-1"
    config.s3_authentication_timeout = 60.minutes

    config.max_file_size   = 300.megabytes
    config.expiration_period = 6.hours

    config.store_dir  = "uploads"
    config.upload_dir = "uploads/tmp"
    config.cache_dir  = 'uploads/cache'
  end
end