Sha256: c8a4dd97d0d23d09fc3df8ca617ca078bbaa1591641d65cd67197e2c4a3c86a0

Contents?: true

Size: 720 Bytes

Versions: 1

Compression:

Stored size: 720 Bytes

Contents

module Slappy
  module Listener
    module Validatable
      include Slappy::Debuggable

      attr_accessor :pattern

      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

      private

      def time_valid?(event)
        event.ts > Slappy.client.start_time
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
slappy-0.6.0 lib/slappy/listeners/concerns/validatable.rb