class PageMagic::Watcher

class WatchedElementDefinition - Contains the specification the for checking if an subject has changed

Attributes

block[R]
context[R]
name[R]
observed_value[R]

Public Class Methods

new(name, context:, &block) click to toggle source

@param [Symbol] name the of the subject being checked @example

Watcher.new(:url) do
  session.url
end
# File lib/page_magic/watcher.rb, line 13
def initialize(name, context:, &block)
  @name = name
  @context = context
  @block = block
end

Public Instance Methods

==(other) click to toggle source

@param [Object] other candidate for equality check @return [Boolen] true of the candiate is equal ot this one.

# File lib/page_magic/watcher.rb, line 30
def ==(other)
  other.is_a?(Watcher) &&
    name == other.name &&
    block == other.block
end
check() click to toggle source

check current value of watched element. The result of the check can be accessed by calling {PageMagic::Watcher#last} if a block was specified to the constructor then this will be executed. @return [PageMagic::Watcher]

# File lib/page_magic/watcher.rb, line 23
def check
  @observed_value = context.instance_eval(&block)
  self
end