Class: Pennyworth::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/pennyworth/processor.rb

Overview

Processes all steps required to render an Alfred Script Filter response.

Instance Method Summary collapse

Constructor Details

#initialize(steps) ⇒ Processor

Returns a new instance of Processor.



6
7
8
9
# File 'lib/pennyworth/processor.rb', line 6

def initialize steps
  @steps = steps
  freeze
end

Instance Method Details

#call(content = nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/pennyworth/processor.rb', line 11

def call content = nil
  loader.call(content)
        .map { |record| presenter.new record }
        .sort_by(&:label)
        .map { |record| serializer.new record }
        .then { |records| {items: records.map(&:to_h)} }
end