Sha256: b52cb6dc9375e463b8a38f921ad3a8680180ff7e5463fda17d24294ee819b350
Contents?: true
Size: 1.3 KB
Versions: 7
Compression:
Stored size: 1.3 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 subject.instance_eval(&block) 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
7 entries across 7 versions & 1 rubygems