Module: S3

Defined in:
lib/s3.rb

Defined Under Namespace

Modules: Attachment

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.bucketObject

Returns the value of attribute bucket.



3
4
5
# File 'lib/s3.rb', line 3

def bucket
  @bucket
end

.keyObject

Returns the value of attribute key.



3
4
5
# File 'lib/s3.rb', line 3

def key
  @key
end

.secretObject

Returns the value of attribute secret.



3
4
5
# File 'lib/s3.rb', line 3

def secret
  @secret
end

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/s3.rb', line 17

def enabled?
  true unless key.blank? or secret.blank? or bucket.blank?
end

.load_s3_config(hash) ⇒ Object



30
31
32
33
34
# File 'lib/s3.rb', line 30

def load_s3_config(hash)
  self.key = hash[:key]
  self.secret = hash[:secret]
  self.bucket = hash[:bucket]
end

.load_s3_yamlObject



21
22
23
24
25
26
27
28
# File 'lib/s3.rb', line 21

def load_s3_yaml
  path = File.join(::Rails.root, 'config', 's3.yml')
  file = File.read(path) if File.exist? path
  if file
    yaml = YAML.load(ERB.new(file).result)[::Rails.env]
    load_s3_config yaml.with_indifferent_access if yaml
  end
end