Sha256: 1f199845f376f5e35701f608ed0ddb5befdaefa3d8088713107796648ca46372

Contents?: true

Size: 946 Bytes

Versions: 9

Compression:

Stored size: 946 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'.freeze

      # 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]
        raise 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

9 entries across 9 versions & 1 rubygems

Version Path
page_magic-1.2.9 lib/page_magic/element/locators.rb
page_magic-1.2.8 lib/page_magic/element/locators.rb
page_magic-1.2.8.alpha lib/page_magic/element/locators.rb
page_magic-1.2.7 lib/page_magic/element/locators.rb
page_magic-1.2.6 lib/page_magic/element/locators.rb
page_magic-1.2.5 lib/page_magic/element/locators.rb
page_magic-1.2.5.alpha1 lib/page_magic/element/locators.rb
page_magic-1.2.4 lib/page_magic/element/locators.rb
page_magic-1.2.3 lib/page_magic/element/locators.rb