Class: Siftly::Filter
- Inherits:
-
Object
- Object
- Siftly::Filter
- Defined in:
- lib/siftly/filter.rb
Class Attribute Summary collapse
-
.key ⇒ Object
readonly
Returns the value of attribute key.
Class Method Summary collapse
Instance Method Summary collapse
- #call(value:, attribute: nil, record: nil, context: {}) ⇒ Object
-
#initialize(config: {}) ⇒ Filter
constructor
A new instance of Filter.
Constructor Details
#initialize(config: {}) ⇒ Filter
Returns a new instance of Filter.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/siftly/filter.rb', line 13 def initialize(config: {}) @config = case config when FilterConfig config.merge({}) when Hash FilterConfig.new(self.class.key || :unknown, config) else raise ConfigurationError, "filter config must be a Hash or FilterConfig" end end |
Class Attribute Details
.key ⇒ Object (readonly)
Returns the value of attribute key.
6 7 8 |
# File 'lib/siftly/filter.rb', line 6 def key @key end |
Class Method Details
.register_as(key) ⇒ Object
8 9 10 |
# File 'lib/siftly/filter.rb', line 8 def register_as(key) @key = key.to_sym end |
Instance Method Details
#call(value:, attribute: nil, record: nil, context: {}) ⇒ Object
25 26 27 |
# File 'lib/siftly/filter.rb', line 25 def call(value:, attribute: nil, record: nil, context: {}) raise NotImplementedError, "#{self.class} must implement #call" end |