Class: Webrat::CulerityLocator
Instance Method Summary collapse
-
#initialize(container, value, element_type, *how) ⇒ CulerityLocator
constructor
A new instance of CulerityLocator.
- #locate ⇒ Object
- #locate! ⇒ Object
Constructor Details
#initialize(container, value, element_type, *how) ⇒ CulerityLocator
Returns a new instance of CulerityLocator.
3 4 5 6 7 8 |
# File 'lib/webrat/culerity/locator.rb', line 3 def initialize(container, value, element_type, *how) @container = container @value = value @element_type = element_type @how = how.blank? ? [:id, :name, :label] : how end |
Instance Method Details
#locate ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/webrat/culerity/locator.rb', line 10 def locate @how.each do |how| e = @container.send(@element_type, how => @value) return e if e.exists? end nil end |
#locate! ⇒ Object
18 19 20 |
# File 'lib/webrat/culerity/locator.rb', line 18 def locate! locate || raise(NotFoundError.new("#{@element_type} matching \"#{@value}\" not found")) end |