Class: Paperclip::Options
- Inherits:
-
Object
- Object
- Paperclip::Options
- Defined in:
- lib/paperclip/options.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
Returns the value of attribute bucket.
-
#convert_options ⇒ Object
Returns the value of attribute convert_options.
-
#default_style ⇒ Object
Returns the value of attribute default_style.
-
#default_url ⇒ Object
Returns the value of attribute default_url.
-
#fog_credentials ⇒ Object
Returns the value of attribute fog_credentials.
-
#fog_directory ⇒ Object
Returns the value of attribute fog_directory.
-
#fog_file ⇒ Object
Returns the value of attribute fog_file.
-
#fog_host ⇒ Object
Returns the value of attribute fog_host.
-
#fog_public ⇒ Object
Returns the value of attribute fog_public.
-
#hash_digest ⇒ Object
Returns the value of attribute hash_digest.
-
#hash_secret ⇒ Object
Returns the value of attribute hash_secret.
-
#http_proxy ⇒ Object
Returns the value of attribute http_proxy.
-
#normalized_styles ⇒ Object
Returns the value of attribute normalized_styles.
-
#only_process ⇒ Object
Returns the value of attribute only_process.
-
#path ⇒ Object
Returns the value of attribute path.
-
#preserve_files ⇒ Object
Returns the value of attribute preserve_files.
-
#s3_credentials ⇒ Object
Returns the value of attribute s3_credentials.
-
#s3_headers ⇒ Object
Returns the value of attribute s3_headers.
-
#s3_host_alias ⇒ Object
Returns the value of attribute s3_host_alias.
-
#s3_host_name ⇒ Object
Returns the value of attribute s3_host_name.
-
#s3_options ⇒ Object
Returns the value of attribute s3_options.
-
#s3_permissions ⇒ Object
Returns the value of attribute s3_permissions.
-
#s3_protocol ⇒ Object
Returns the value of attribute s3_protocol.
-
#source_file_options ⇒ Object
Returns the value of attribute source_file_options.
-
#storage ⇒ Object
Returns the value of attribute storage.
-
#url ⇒ Object
Returns the value of attribute url.
-
#use_default_time_zone ⇒ Object
Returns the value of attribute use_default_time_zone.
-
#use_timestamp ⇒ Object
Returns the value of attribute use_timestamp.
-
#whiny ⇒ Object
Returns the value of attribute whiny.
Instance Method Summary collapse
-
#initialize(attachment, hash) ⇒ Options
constructor
A new instance of Options.
- #method_missing(method, *args, &blk) ⇒ Object
- #processors ⇒ Object
- #styles ⇒ Object
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(, hash) @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
#bucket ⇒ Object
Returns the value of attribute bucket.
8 9 10 |
# File 'lib/paperclip/options.rb', line 8 def bucket @bucket end |
#convert_options ⇒ Object
Returns the value of attribute convert_options.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def @convert_options end |
#default_style ⇒ Object
Returns the value of attribute default_style.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def default_style @default_style end |
#default_url ⇒ Object
Returns the value of attribute default_url.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def default_url @default_url end |
#fog_credentials ⇒ Object
Returns the value of attribute fog_credentials.
11 12 13 |
# File 'lib/paperclip/options.rb', line 11 def fog_credentials @fog_credentials end |
#fog_directory ⇒ Object
Returns the value of attribute fog_directory.
11 12 13 |
# File 'lib/paperclip/options.rb', line 11 def fog_directory @fog_directory end |
#fog_file ⇒ Object
Returns the value of attribute fog_file.
11 12 13 |
# File 'lib/paperclip/options.rb', line 11 def fog_file @fog_file end |
#fog_host ⇒ Object
Returns the value of attribute fog_host.
11 12 13 |
# File 'lib/paperclip/options.rb', line 11 def fog_host @fog_host end |
#fog_public ⇒ Object
Returns the value of attribute fog_public.
11 12 13 |
# File 'lib/paperclip/options.rb', line 11 def fog_public @fog_public end |
#hash_digest ⇒ Object
Returns the value of attribute hash_digest.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def hash_digest @hash_digest end |
#hash_secret ⇒ Object
Returns the value of attribute hash_secret.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def hash_secret @hash_secret end |
#http_proxy ⇒ Object
Returns the value of attribute http_proxy.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def http_proxy @http_proxy end |
#normalized_styles ⇒ Object
Returns the value of attribute normalized_styles.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def normalized_styles @normalized_styles end |
#only_process ⇒ Object
Returns the value of attribute only_process.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def only_process @only_process end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def path @path end |
#preserve_files ⇒ Object
Returns the value of attribute preserve_files.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def preserve_files @preserve_files end |
#s3_credentials ⇒ Object
Returns the value of attribute s3_credentials.
8 9 10 |
# File 'lib/paperclip/options.rb', line 8 def s3_credentials @s3_credentials end |
#s3_headers ⇒ Object
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_alias ⇒ Object
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_name ⇒ Object
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_options ⇒ Object
Returns the value of attribute s3_options.
8 9 10 |
# File 'lib/paperclip/options.rb', line 8 def @s3_options end |
#s3_permissions ⇒ Object
Returns the value of attribute s3_permissions.
8 9 10 |
# File 'lib/paperclip/options.rb', line 8 def @s3_permissions end |
#s3_protocol ⇒ Object
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_options ⇒ Object
Returns the value of attribute source_file_options.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def @source_file_options end |
#storage ⇒ Object
Returns the value of attribute storage.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def storage @storage end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def url @url end |
#use_default_time_zone ⇒ Object
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_timestamp ⇒ Object
Returns the value of attribute use_timestamp.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def @use_timestamp end |
#whiny ⇒ Object
Returns the value of attribute whiny.
4 5 6 |
# File 'lib/paperclip/options.rb', line 4 def whiny @whiny end |
Instance Method Details
#processors ⇒ Object
64 65 66 |
# File 'lib/paperclip/options.rb', line 64 def processors @processors.respond_to?(:call) ? @processors.call(@attachment.instance) : @processors end |
#styles ⇒ Object
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 |