Module: CodelessCode::Filters::Builders

Included in:
CodelessCode::Filters
Defined in:
lib/codeless_code/filters/builders.rb

Overview

Module functions to generate filter subclasses.

Class Method Summary collapse

Class Method Details

.header_integer_filter(name) ⇒ Object


24
25
26
# File 'lib/codeless_code/filters/builders.rb', line 24

def header_integer_filter(name)
  subclass_filter(Headers::Integer, name)
end

.header_string_filter(name) ⇒ Object


28
29
30
# File 'lib/codeless_code/filters/builders.rb', line 28

def header_string_filter(name)
  subclass_filter(Headers::String, name)
end

.subclass_filter(klass, name) ⇒ Object


32
33
34
35
36
37
38
# File 'lib/codeless_code/filters/builders.rb', line 32

def subclass_filter(klass, name)
  const_set(name, Class.new(klass) do
    def initialize(*args)
      super(self.class.name.split(':').last, *args)
    end
  end)
end