Module: Workarea::Configuration::Dragonfly

Extended by:
Dragonfly
Included in:
Dragonfly
Defined in:
lib/workarea/configuration/dragonfly.rb

Instance Method Summary collapse

Instance Method Details

#file_system_defaultsObject



35
36
37
38
39
40
# File 'lib/workarea/configuration/dragonfly.rb', line 35

def file_system_defaults
  {
    root_path: Rails.root.join('public/system/workarea', Rails.env).to_s,
    server_root: Rails.root.join('public').to_s
  }
end

#loadObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/workarea/configuration/dragonfly.rb', line 6

def load
  type, options = *Workarea.config.asset_store
  options = (options || {}).with_indifferent_access

  if type == :s3 && S3.bucket.present?
    options.reverse_merge!(s3_defaults)
  elsif %i(file file_system).include?(type)
    type = :file
    options.reverse_merge!(file_system_defaults)
  end

  ::Dragonfly.app(:workarea).configure do
    # Ensure Dragonfly always uses the CDN no matter what
    url_host Rails.application.config.action_controller.asset_host
    datastore type, options
  end
end

#s3_defaultsObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/workarea/configuration/dragonfly.rb', line 24

def s3_defaults
  {
    region: S3.region,
    bucket_name: S3.bucket,
    access_key_id: S3.access_key_id,
    secret_access_key: S3.secret_access_key,
    use_iam_profile: S3.access_key_id.blank?,
    storage_headers: { 'x-amz-acl' => 'private' }
  }
end