Class: Sprockets::LegacyProcProcessor

Inherits:
Delegator
  • Object
show all
Defined in:
lib/sprockets/legacy_proc_processor.rb

Overview

Deprecated: Wraps legacy process Procs with new processor call signature.

Will be removed in Sprockets 4.x.

LegacyProcProcessor.new(:compress,
  proc { |context, data| data.gsub(...) })

Instance Method Summary collapse

Constructor Details

#initialize(name, proc) ⇒ LegacyProcProcessor

Returns a new instance of LegacyProcProcessor



12
13
14
15
# File 'lib/sprockets/legacy_proc_processor.rb', line 12

def initialize(name, proc)
  @name = name
  @proc = proc
end

Instance Method Details

#__getobj__Object



17
18
19
# File 'lib/sprockets/legacy_proc_processor.rb', line 17

def __getobj__
  @proc
end

#call(input) ⇒ Object



29
30
31
32
33
# File 'lib/sprockets/legacy_proc_processor.rb', line 29

def call(input)
  context = input[:environment].context_class.new(input)
  data = @proc.call(context, input[:data])
  context..merge(data: data)
end

#nameObject



21
22
23
# File 'lib/sprockets/legacy_proc_processor.rb', line 21

def name
  "Sprockets::LegacyProcProcessor (#{@name})"
end

#to_sObject



25
26
27
# File 'lib/sprockets/legacy_proc_processor.rb', line 25

def to_s
  name
end