Class: PaperclipCompression::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/paperclip-compression/config.rb

Constant Summary collapse

PROCESSOR_OPTIONS_KEY =
:processor_options
KEY =
:compression

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, type_key, fallback, whiny) ⇒ Config

Returns a new instance of Config.



13
14
15
16
17
# File 'lib/paperclip-compression/config.rb', line 13

def initialize(options, type_key, fallback, whiny)
  @whiny = whiny
  @fallback = fallback
  parse_options(options, type_key)
end

Class Method Details

.create_with_fallbacks(style_options, type_key, gem_defaults) ⇒ Object



7
8
9
10
11
# File 'lib/paperclip-compression/config.rb', line 7

def self.create_with_fallbacks(style_options, type_key, gem_defaults)
  gem_config = new({ KEY => { type_key => gem_defaults } }, type_key, nil, nil)
  defaults_config = new(Paperclip::Attachment.default_options, type_key, gem_config, Paperclip::Attachment.default_options[:whiny])
  new(style_options[PROCESSOR_OPTIONS_KEY], type_key, defaults_config, style_options[:whiny])
end

Instance Method Details

#commandObject



29
30
31
32
33
34
35
36
37
# File 'lib/paperclip-compression/config.rb', line 29

def command
  if defined?(@command)
    @command
  elsif @fallback
    @fallback.command
  else
    raise("options or fallback should have 'command'")
  end
end

#optionsObject



39
40
41
42
43
44
45
46
47
# File 'lib/paperclip-compression/config.rb', line 39

def options
  if defined?(@options)
    @options
  elsif @fallback
    @fallback.options
  else
    raise("options or fallback should have 'options'")
  end
end

#process_file?Boolean

Returns:

  • (Boolean)


19
20
21
22
23
24
25
26
27
# File 'lib/paperclip-compression/config.rb', line 19

def process_file?
  if defined?(@process_file)
    @process_file
  elsif @fallback
    @fallback.process_file?
  else
    raise('options or fallback should have attributes')
  end
end

#whinyObject



49
50
51
# File 'lib/paperclip-compression/config.rb', line 49

def whiny
  @whiny
end