Class: Superfluid::Registries::Filter
- Inherits:
-
Data
- Object
- Data
- Superfluid::Registries::Filter
- Defined in:
- lib/superfluid/registries/filter.rb
Overview
A filter registry.
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
Class Method Summary collapse
Instance Method Summary collapse
- #add ⇒ Object
- #call(name) ⇒ Object (also: #invoke)
- #clear ⇒ Object
-
#initialize(mode: :strict, commands: {}) ⇒ Filter
constructor
A new instance of Filter.
- #names ⇒ Object
Constructor Details
#initialize(mode: :strict, commands: {}) ⇒ Filter
Returns a new instance of Filter.
9 10 11 |
# File 'lib/superfluid/registries/filter.rb', line 9 def initialize mode: :strict, commands: {} super end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands
6 7 8 |
# File 'lib/superfluid/registries/filter.rb', line 6 def commands @commands end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode
6 7 8 |
# File 'lib/superfluid/registries/filter.rb', line 6 def mode @mode end |
Class Method Details
.for(namespace = Liquid::StandardFilters, mode: :strict) ⇒ Object
7 |
# File 'lib/superfluid/registries/filter.rb', line 7 def self.for(namespace = Liquid::StandardFilters, mode: :strict) = new(mode:).add namespace |
Instance Method Details
#add ⇒ Object
13 14 15 16 17 |
# File 'lib/superfluid/registries/filter.rb', line 13 def add(*, **) add_namespaces(*) add_commands(**) self end |
#call(name) ⇒ Object Also known as: invoke
19 20 21 22 23 |
# File 'lib/superfluid/registries/filter.rb', line 19 def call(name, *) dispatch(name, *) rescue ArgumentError => error raise Liquid::ArgumentError, error., error.backtrace end |
#clear ⇒ Object
27 28 29 30 |
# File 'lib/superfluid/registries/filter.rb', line 27 def clear commands.clear self end |
#names ⇒ Object
32 |
# File 'lib/superfluid/registries/filter.rb', line 32 def names = commands.keys |