Class: Rails::WebP::PostProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/rails/webp/post_processor.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename, &block) ⇒ PostProcessor

Returns a new instance of PostProcessor.



4
5
6
7
# File 'lib/rails/webp/post_processor.rb', line 4

def initialize(filename, &block)
  @filename = filename
  @source   = block.call
end

Class Method Details

.call(input) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rails/webp/post_processor.rb', line 17

def self.call(input)
  filename = input[:filename]
  source   = input[:data]
  context  = input[:environment].context_class.new(input)

  result = run(filename, source, context)
  context..merge(data: result)
end

.run(filename, data, context) ⇒ Object



13
14
15
# File 'lib/rails/webp/post_processor.rb', line 13

def self.run(filename, data, context)
  Converter.process(filename, data, context)
end

Instance Method Details

#render(context, empty_hash_wtf) ⇒ Object



9
10
11
# File 'lib/rails/webp/post_processor.rb', line 9

def render(context, empty_hash_wtf)
  self.class.run(@filename, @source, context)
end