Class: Paperclip::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/paperclip/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attachment, hash) ⇒ Options

Returns a new instance of Options.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/paperclip/options.rb', line 13

def initialize(attachment, hash)
  @attachment            = attachment

  @url                   = hash[:url]
  @url                   = @url.call(@attachment) if @url.is_a?(Proc)
  @path                  = hash[:path]
  @path                  = @path.call(@attachment) if @path.is_a?(Proc)
  @styles                = hash[:styles]
  @only_process          = hash[:only_process]
  @normalized_styles     = nil
  @default_url           = hash[:default_url]
  @default_style         = hash[:default_style]
  @storage               = hash[:storage]
  @use_timestamp         = hash[:use_timestamp]
  @whiny                 = hash[:whiny_thumbnails] || hash[:whiny]
  @use_default_time_zone = hash[:use_default_time_zone]
  @hash_digest           = hash[:hash_digest]
  @hash_data             = hash[:hash_data]
  @hash_secret           = hash[:hash_secret]
  @convert_options       = hash[:convert_options]
  @source_file_options   = hash[:source_file_options]
  @processors            = hash[:processors]
  @preserve_files        = hash[:preserve_files]
  @http_proxy            = hash[:http_proxy]

  #s3 options
  @s3_credentials        = hash[:s3_credentials]
  @s3_host_name          = hash[:s3_host_name]
  @bucket                = hash[:bucket]
  @s3_options            = hash[:s3_options]
  @s3_permissions        = hash[:s3_permissions]
  @s3_protocol           = hash[:s3_protocol]
  @s3_headers            = hash[:s3_headers]
  @s3_host_alias         = hash[:s3_host_alias]

  #fog options
  @fog_directory         = hash[:fog_directory]
  @fog_credentials       = hash[:fog_credentials]
  @fog_host              = hash[:fog_host]
  @fog_public            = hash[:fog_public]
  @fog_file              = hash[:fog_file]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &blk) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/paperclip/options.rb', line 56

def method_missing(method, *args, &blk)
  if method.to_s[-1,1] == "="
    instance_variable_set("@#{method[0..-2]}", args[0])
  else
    instance_variable_get("@#{method}")
  end
end

Instance Attribute Details

#bucketObject

Returns the value of attribute bucket.



8
9
10
# File 'lib/paperclip/options.rb', line 8

def bucket
  @bucket
end

#convert_optionsObject

Returns the value of attribute convert_options.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def convert_options
  @convert_options
end

#default_styleObject

Returns the value of attribute default_style.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def default_style
  @default_style
end

#default_urlObject

Returns the value of attribute default_url.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def default_url
  @default_url
end

#fog_credentialsObject

Returns the value of attribute fog_credentials.



11
12
13
# File 'lib/paperclip/options.rb', line 11

def fog_credentials
  @fog_credentials
end

#fog_directoryObject

Returns the value of attribute fog_directory.



11
12
13
# File 'lib/paperclip/options.rb', line 11

def fog_directory
  @fog_directory
end

#fog_fileObject

Returns the value of attribute fog_file.



11
12
13
# File 'lib/paperclip/options.rb', line 11

def fog_file
  @fog_file
end

#fog_hostObject

Returns the value of attribute fog_host.



11
12
13
# File 'lib/paperclip/options.rb', line 11

def fog_host
  @fog_host
end

#fog_publicObject

Returns the value of attribute fog_public.



11
12
13
# File 'lib/paperclip/options.rb', line 11

def fog_public
  @fog_public
end

#hash_digestObject

Returns the value of attribute hash_digest.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def hash_digest
  @hash_digest
end

#hash_secretObject

Returns the value of attribute hash_secret.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def hash_secret
  @hash_secret
end

#http_proxyObject

Returns the value of attribute http_proxy.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def http_proxy
  @http_proxy
end

#normalized_stylesObject

Returns the value of attribute normalized_styles.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def normalized_styles
  @normalized_styles
end

#only_processObject

Returns the value of attribute only_process.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def only_process
  @only_process
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def path
  @path
end

#preserve_filesObject

Returns the value of attribute preserve_files.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def preserve_files
  @preserve_files
end

#s3_credentialsObject

Returns the value of attribute s3_credentials.



8
9
10
# File 'lib/paperclip/options.rb', line 8

def s3_credentials
  @s3_credentials
end

#s3_headersObject

Returns the value of attribute s3_headers.



8
9
10
# File 'lib/paperclip/options.rb', line 8

def s3_headers
  @s3_headers
end

#s3_host_aliasObject

Returns the value of attribute s3_host_alias.



8
9
10
# File 'lib/paperclip/options.rb', line 8

def s3_host_alias
  @s3_host_alias
end

#s3_host_nameObject

Returns the value of attribute s3_host_name.



8
9
10
# File 'lib/paperclip/options.rb', line 8

def s3_host_name
  @s3_host_name
end

#s3_optionsObject

Returns the value of attribute s3_options.



8
9
10
# File 'lib/paperclip/options.rb', line 8

def s3_options
  @s3_options
end

#s3_permissionsObject

Returns the value of attribute s3_permissions.



8
9
10
# File 'lib/paperclip/options.rb', line 8

def s3_permissions
  @s3_permissions
end

#s3_protocolObject

Returns the value of attribute s3_protocol.



8
9
10
# File 'lib/paperclip/options.rb', line 8

def s3_protocol
  @s3_protocol
end

#source_file_optionsObject

Returns the value of attribute source_file_options.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def source_file_options
  @source_file_options
end

#storageObject

Returns the value of attribute storage.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def storage
  @storage
end

#urlObject

Returns the value of attribute url.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def url
  @url
end

#use_default_time_zoneObject

Returns the value of attribute use_default_time_zone.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def use_default_time_zone
  @use_default_time_zone
end

#use_timestampObject

Returns the value of attribute use_timestamp.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def use_timestamp
  @use_timestamp
end

#whinyObject

Returns the value of attribute whiny.



4
5
6
# File 'lib/paperclip/options.rb', line 4

def whiny
  @whiny
end

Instance Method Details

#processorsObject



64
65
66
# File 'lib/paperclip/options.rb', line 64

def processors
  @processors.respond_to?(:call) ? @processors.call(@attachment.instance) : @processors
end

#stylesObject



68
69
70
71
72
73
74
75
76
# File 'lib/paperclip/options.rb', line 68

def styles
  if @styles.respond_to?(:call) || !@normalized_styles
    @normalized_styles = ActiveSupport::OrderedHash.new
    (@styles.respond_to?(:call) ? @styles.call(@attachment) : @styles).each do |name, args|
      normalized_styles[name] = Paperclip::Style.new(name, args.dup, @attachment)
    end
  end
  @normalized_styles
end