Module: SitePrism::DSL::ClassMethods

Defined in:
lib/site_prism/dsl.rb

Overview

rubocop:disable Metrics/ModuleLength

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expected_itemsObject (readonly)

Returns the value of attribute expected_items.



78
79
80
# File 'lib/site_prism/dsl.rb', line 78

def expected_items
  @expected_items
end

Instance Method Details

#element(name, *find_args) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/site_prism/dsl.rb', line 80

def element(name, *find_args)
  build(:element, name, *find_args) do
    define_method(name) do |*runtime_args, &element_block|
      raise_if_block(self, name, !element_block.nil?, :element)
      _find(*merge_args(find_args, runtime_args))
    end
  end
end

#elements(name, *find_args) ⇒ Object



89
90
91
92
93
94
95
96
# File 'lib/site_prism/dsl.rb', line 89

def elements(name, *find_args)
  build(:elements, name, *find_args) do
    define_method(name) do |*runtime_args, &element_block|
      raise_if_block(self, name, !element_block.nil?, :elements)
      _all(*merge_args(find_args, runtime_args))
    end
  end
end

#expected_elements(*elements) ⇒ Object



98
99
100
# File 'lib/site_prism/dsl.rb', line 98

def expected_elements(*elements)
  @expected_items = elements
end

#iframe(name, klass, *args) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/site_prism/dsl.rb', line 124

def iframe(name, klass, *args)
  element_find_args = deduce_iframe_element_find_args(args)
  scope_find_args = deduce_iframe_scope_find_args(args)
  map_item!(:iframe, name)
  add_iframe_helper_methods(name, *element_find_args)
  define_method(name) do |&block|
    raise MissingBlockError unless block

    within_frame(*scope_find_args) do
      block.call(klass.new)
    end
  end
end

#mapped_itemsObject



138
139
140
# File 'lib/site_prism/dsl.rb', line 138

def mapped_items
  @mapped_items ||= []
end

#section(name, *args, &block) ⇒ Object



102
103
104
105
106
107
108
109
110
# File 'lib/site_prism/dsl.rb', line 102

def section(name, *args, &block)
  section_class, find_args = extract_section_options(args, &block)
  build(:section, name, *find_args) do
    define_method(name) do |*runtime_args, &runtime_block|
      section_element = _find(*merge_args(find_args, runtime_args))
      section_class.new(self, section_element, &runtime_block)
    end
  end
end

#sections(name, *args, &block) ⇒ Object



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/site_prism/dsl.rb', line 112

def sections(name, *args, &block)
  section_class, find_args = extract_section_options(args, &block)
  build(:sections, name, *find_args) do
    define_method(name) do |*runtime_args, &element_block|
      raise_if_block(self, name, !element_block.nil?, :sections)
      _all(*merge_args(find_args, runtime_args)).map do |element|
        section_class.new(self, element)
      end
    end
  end
end