Class: Banzai::Filter
- Inherits:
-
Object
- Object
- Banzai::Filter
- 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
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.call(input) ⇒ Object
Delegates to #call by creating an instance with default options.
Instance Method Summary collapse
-
#call(input) ⇒ Object
Subclass should redefine this method to transform input to desired output.
-
#initialize(options = {}) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(options = {}) ⇒ Filter
Returns a new instance of Filter.
11 12 13 |
# File 'lib/banzai/filter.rb', line 11 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/banzai/filter.rb', line 7 def @options end |
Class Method Details
.call(input) ⇒ Object
Delegates to #call by creating an instance with default options
28 29 30 |
# File 'lib/banzai/filter.rb', line 28 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. Input and return value should be the same type to provide way of chaining filters
21 22 23 |
# File 'lib/banzai/filter.rb', line 21 def call(input) input end |