Module: PageMagic::Elements
- Included in:
- Element
- Defined in:
- lib/page_magic/elements.rb
Overview
module Elements - contains methods that add element definitions to the objects it is mixed in to
Defined Under Namespace
Modules: InheritanceHooks
Constant Summary collapse
- INVALID_METHOD_NAME_MSG =
'a method already exists with this method name'.freeze
- TYPES =
[:text_field, :button, :link, :checkbox, :select_list, :radios, :textarea].freeze
Instance Method Summary collapse
-
#element(*args, &block) ⇒ Object
Creates an element defintion.
-
#element_definitions ⇒ Hash
Element definition names mapped to blocks that can be used to create unique instances of and Element definitions.
Instance Method Details
#element(name, selector, &block) ⇒ Object #element(element_class, &block) ⇒ Object #element(name, element_class, &block) ⇒ Object #element(name, element_class, selector, &block) ⇒ Object
Creates an element defintion. Element defintions contain specifications for locating them and other sub elements. if a block is specified then it will be executed against the element defintion. This method is aliased to each of the names specified in TYPES
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/page_magic/elements.rb', line 53 def element(*args, &block) block ||= proc {} = (args.dup) [:type] = __callee__ section_class = .delete(:section_class) add_element_definition(.delete(:name)) do |parent_element, *e_args| definition_class = Class.new(section_class) do parent_element(parent_element) class_exec(*e_args, &block) end ElementDefinitionBuilder.new(.merge(definition_class: definition_class)) end end |
#element_definitions ⇒ Hash
Returns element definition names mapped to blocks that can be used to create unique instances of and PageMagic::Element definitions.
72 73 74 |
# File 'lib/page_magic/elements.rb', line 72 def element_definitions @element_definitions ||= {} end |