Sha256: e2d8ea5c0d135502cc2229d2fd0585afffae958a799a795b1cb98610f2c50994
Contents?: true
Size: 1.28 KB
Versions: 10
Compression:
Stored size: 1.28 KB
Contents
module PageMagic # class WatchedElementDefinition - Contains the specification the for checking if an subject has changed class Watcher attr_reader :name, :attribute, :last, :block # @param [Symbol] name the of the subject being checked # @param [Symbol] method the method that should be called on the subject being checked # @example # Watcher.new(:text) # Watcher.new do # session.url # end def initialize(name, method = nil, &block) @name = name @attribute = method @block = block end # check current value of watched element. The result of the check is stored against {Watcher#last} # a block was specified then this will be executed. # @param [Object] subject - subject to run watcher against def check(subject = nil) @last = if block block.call else object = subject.send(name) attribute ? object.send(attribute) : object end self end # @param [Object] other candidate for equality check # @return [Boolen] true of the candiate is equal ot this one. def ==(other) other.is_a?(Watcher) && name == other.name && attribute == other.attribute && block == other.block end end end
Version data entries
10 entries across 10 versions & 1 rubygems