Module: Slappy::Listener::Validatable

Includes:
Debuggable
Included in:
Base
Defined in:
lib/slappy/listeners/concerns/validatable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Debuggable

included

Instance Attribute Details

#patternObject

Returns the value of attribute pattern.



6
7
8
# File 'lib/slappy/listeners/concerns/validatable.rb', line 6

def pattern
  @pattern
end

Instance Method Details

#valid?(event) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/slappy/listeners/concerns/validatable.rb', line 8

def valid?(event)
  unless time_valid?(event)
    Debug.log 'Event happend in before start time'
    return false
  end

  target = event.send(target_element)
  unless target
    Debug.log 'Target is nil'
    return false
  end

  event.matches = target.match pattern
  unless event.matches
    Debug.log "Target is not match pattern(#{pattern})"
    return false
  end

  true
end