Class: AlterEgo::RequestFilter

Inherits:
Struct
  • Object
show all
Defined in:
lib/alter_ego.rb,
lib/alter_ego.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionObject

Returns the value of attribute action

Returns:

  • (Object)

    the current value of action



29
30
31
# File 'lib/alter_ego.rb', line 29

def action
  @action
end

#new_stateObject

Returns the value of attribute new_state

Returns:

  • (Object)

    the current value of new_state



29
30
31
# File 'lib/alter_ego.rb', line 29

def new_state
  @new_state
end

#requestObject

Returns the value of attribute request

Returns:

  • (Object)

    the current value of request



29
30
31
# File 'lib/alter_ego.rb', line 29

def request
  @request
end

#stateObject

Returns the value of attribute state

Returns:

  • (Object)

    the current value of state



29
30
31
# File 'lib/alter_ego.rb', line 29

def state
  @state
end

Instance Method Details

#===(other) ⇒ Object



35
36
37
38
39
40
# File 'lib/alter_ego.rb', line 35

def ===(other)
  result = (matches?(self.state, other.state) and
            matches?(self.request, other.request) and
            matches?(self.new_state, other.new_state))
 result
end

#matches?(lhs, rhs) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
48
# File 'lib/alter_ego.rb', line 42

def matches?(lhs, rhs)
  if rhs.respond_to?(:include?)
    rhs.include?(lhs)
  else
    rhs == lhs
  end
end