Sha256: b8e617c02130e063fbc54a3e57dbab24250c3d0368815fab86030b291ba39791

Contents?: true

Size: 938 Bytes

Versions: 6

Compression:

Stored size: 938 Bytes

Contents

module PageMagic
  # for the benefit of pull review :@
  class Element
    # contains method for finding element definitions
    module Locators
      # message used when raising {ElementMissingException} from methods within this module
      ELEMENT_NOT_DEFINED_MSG = 'Element not defined: %s'

      # find an element definition based on its name
      # @param [Symbol] name name of the element
      # @return [Element] element definition with the given name
      # @raise [ElementMissingException] raised when element with the given name is not found
      def element_by_name(name, *args)
        defintion = element_definitions[name]
        fail ElementMissingException, (ELEMENT_NOT_DEFINED_MSG % name) unless defintion
        defintion.call(self, *args)
      end

      # @return [Array] class level defined element definitions
      def element_definitions
        self.class.element_definitions
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
page_magic-1.2.1 lib/page_magic/element/locators.rb
page_magic-1.2.0 lib/page_magic/element/locators.rb
page_magic-1.1.0 lib/page_magic/element/locators.rb
page_magic-1.0.4 lib/page_magic/element/locators.rb
page_magic-1.0.3 lib/page_magic/element/locators.rb
page_magic-1.0.2 lib/page_magic/element/locators.rb