Class: Banzai::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/banzai/filter.rb

Overview

Filter transforms an input into desired output. The process of transformation should be implemented in the #call method.

Direct Known Subclasses

Pipeline

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Filter

Returns a new instance of Filter.

Parameters:

  • options (Hash) (defaults to: {})

    filter parameters that method #call can utilize to make processing customizable



9
10
11
# File 'lib/banzai/filter.rb', line 9

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/banzai/filter.rb', line 5

def options
  @options
end

Class Method Details

.call(input) ⇒ Object

Delegates to #call by creating an instance with default options

Parameters:

  • input (Object)


24
25
26
# File 'lib/banzai/filter.rb', line 24

def self.call(input)
  new.call(input)
end

Instance Method Details

#call(input) ⇒ Object

Subclass should redefine this method to transform input to desired output

Parameters:

  • input (Object)

    the type of the input is not defined since it will depend on the (re)implementation of the method



17
18
19
# File 'lib/banzai/filter.rb', line 17

def call(input)
  input
end