Class: Superfluid::Registries::Filter

Inherits:
Data
  • Object
show all
Defined in:
lib/superfluid/registries/filter.rb

Overview

A filter registry.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#commandsObject (readonly)

Returns the value of attribute commands

Returns:

  • (Object)

    the current value of commands



6
7
8
# File 'lib/superfluid/registries/filter.rb', line 6

def commands
  @commands
end

#modeObject (readonly)

Returns the value of attribute mode

Returns:

  • (Object)

    the current value of 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

#addObject



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.message, error.backtrace
end

#clearObject



27
28
29
30
# File 'lib/superfluid/registries/filter.rb', line 27

def clear
  commands.clear
  self
end

#namesObject



32
# File 'lib/superfluid/registries/filter.rb', line 32

def names = commands.keys