Module: SitePrism::Loadable::ClassMethods

Defined in:
lib/site_prism/loadable.rb

Instance Method Summary collapse

Instance Method Details

#load_validation(&block) ⇒ Object

Appends a load validation block to the page class.

When ‘loaded?` is called, these blocks are instance_eval’d against the current page instance. This allows users to wait for specific events to occur on the page or certain elements to be loaded before performing any actions on the page.

loaded successfully, or false if it did not. This block can contain up to 2 elements in an array The first is the physical validation test to be truthily evaluated If this does not pass, then the 2nd item (If defined), is output as an error message to the FailedLoadValidationError that is thrown

Parameters:

  • block (&block)

    A block which returns true if the page



32
33
34
# File 'lib/site_prism/loadable.rb', line 32

def load_validation(&block)
  _load_validations << block
end

#load_validationsArray

The list of load_validations. They will be executed in the order they are defined.

Returns:

  • (Array)


10
11
12
13
14
15
16
# File 'lib/site_prism/loadable.rb', line 10

def load_validations
  if superclass.respond_to?(:load_validations)
    superclass.load_validations + _load_validations
  else
    _load_validations
  end
end