Class: Typhoeus::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/typhoeus/filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_name, options = {}) ⇒ Filter

Returns a new instance of Filter.



5
6
7
8
# File 'lib/typhoeus/filter.rb', line 5

def initialize(method_name, options = {})
  @method_name = method_name
  @options = options
end

Instance Attribute Details

#method_nameObject (readonly)

Returns the value of attribute method_name.



3
4
5
# File 'lib/typhoeus/filter.rb', line 3

def method_name
  @method_name
end

Instance Method Details

#apply_filter?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/typhoeus/filter.rb', line 10

def apply_filter?(method_name)
  if @options[:only]
    if @options[:only].instance_of? Symbol
      @options[:only] == method_name
    else
      @options[:only].include?(method_name)
    end
  elsif @options[:except]
    if @options[:except].instance_of? Symbol
      @options[:except] != method_name
    else
      !@options[:except].include?(method_name)
    end
  else
    true
  end
end