Module: AmpleAssets::Configuration

Included in:
AmpleAssets
Defined in:
lib/ample_assets/configuration.rb

Overview

Defines constants and methods related to configuration

Constant Summary collapse

VALID_OPTIONS_KEYS =

An array of valid keys in the options hash when configuring

[
:mount_at,
:dfly,
:tabs,
:icons,
:allowed_mime_types].freeze
DEFAULT_MOUNT_AT =

Route path prefix

'/ample_assets/'
DEFAULT_DFLY =

Access to Dragonfly

DEFAULT_TABS =

Tabs available in the Assets Toolbar

[
  { :id => 'recent-assets', :title => 'Recently Viewed', :url => '/ample_assets/files/recent', :panels => true, :data_type => 'json' },
  { :id => 'image-assets', :title => 'Images', :url => '/ample_assets/files/images', :panels => true, :data_type => 'json' },
  { :id => 'document-assets', :title => 'Documents', :url => '/ample_assets/files/documents', :panels => true, :data_type => 'json' },
  { :id => 'upload', :title => 'Upload', :url => '/ample_assets/files/new' }
]
DEFAULT_ALLOWED_MIME_TYPES =

File types available for upload

{
  :images => %w(image/jpeg image/png image/gif),
  :documents => %w(application/pdf),
  :other => %w(application/x-shockwave-flash)
}
DEFAULT_ICONS =
{
  'application/x-shockwave-flash' => '/assets/ample_assets/icon_swf.gif',
  'application/pdf' => '/assets/ample_assets/icon_pdf.gif',
  :other => '/assets/ample_assets/icon_other.gif'
}

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values



46
47
48
# File 'lib/ample_assets/configuration.rb', line 46

def self.extended(base)
  base.reset
end

Instance Method Details

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

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:



51
52
53
# File 'lib/ample_assets/configuration.rb', line 51

def configure
  yield self
end

#optionsObject

Create a hash of options and their values



56
57
58
59
60
# File 'lib/ample_assets/configuration.rb', line 56

def options
  options = {}
  VALID_OPTIONS_KEYS.each{|k| options[k] = send(k)}
  options
end

#resetObject

Reset all configuration options to defaults



63
64
65
66
67
68
69
70
# File 'lib/ample_assets/configuration.rb', line 63

def reset
  self.mount_at = DEFAULT_MOUNT_AT
  self.dfly = DEFAULT_DFLY
  self.tabs = DEFAULT_TABS
  self.allowed_mime_types = DEFAULT_ALLOWED_MIME_TYPES
  self.icons = DEFAULT_ICONS
  self
end