Class: Watirmark::WebPage::Controller

Inherits:
Object
  • Object
show all
Includes:
Actions, Assertions, Dialogs
Defined in:
lib/watirmark/controller/controller.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes included from Actions

#records

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions

#activate, #after_all, #after_each, #archive, #before_all, #before_each, #check_defaults, #check_for_noop_populate, #copy, #create, #create_until, #deactivate, #delete, #edit, #edit_until, #get, #locate_record, #populate_data_overridden?, #publish, #restore, #run, #search_for_record, #starts_with, #unpublish, #verify, #verify_until

Methods included from Dialogs

#close_chrome_windows, #close_modal_window, #current_window_index, #modal_exists?, #wait_for_modal_dialog, #with_modal_dialog

Constructor Details

#initialize(data = {}) ⇒ Controller

Returns a new instance of Controller.



25
26
27
28
29
30
31
# File 'lib/watirmark/controller/controller.rb', line 25

def initialize(data = {})
  initialize_model(data)
  @records ||= []
  @cache = {}
  @view = self.class.view.new browser if self.class.view
  @search = self.class.search
end

Class Attribute Details

.modelObject

Returns the value of attribute model.



16
17
18
# File 'lib/watirmark/controller/controller.rb', line 16

def model
  @model
end

.searchObject

Returns the value of attribute search.



16
17
18
# File 'lib/watirmark/controller/controller.rb', line 16

def search
  @search
end

.viewObject

Returns the value of attribute view.



16
17
18
# File 'lib/watirmark/controller/controller.rb', line 16

def view
  @view
end

Instance Attribute Details

#modelObject

Returns the value of attribute model.



10
11
12
# File 'lib/watirmark/controller/controller.rb', line 10

def model
  @model
end

#supermodelObject (readonly)

Returns the value of attribute supermodel.



10
11
12
# File 'lib/watirmark/controller/controller.rb', line 10

def supermodel
  @supermodel
end

Class Method Details

.inherited(klass) ⇒ Object



18
19
20
21
22
# File 'lib/watirmark/controller/controller.rb', line 18

def inherited(klass)
  klass.view ||= @view if @view
  klass.model ||= @model if @model
  klass.search ||= @search if @search
end

Instance Method Details

#browserObject



33
34
35
# File 'lib/watirmark/controller/controller.rb', line 33

def browser
  Page.browser
end

#populate_data(updates = nil) ⇒ Object



41
42
43
# File 'lib/watirmark/controller/controller.rb', line 41

def populate_data(updates=nil)
  submit_process_page(@last_process_page.underscored_name) {submit} if populate_values(updates)
end

#populate_values(updates = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/watirmark/controller/controller.rb', line 45

def populate_values(updates=nil)
  @seen_value = false
  @last_process_page = nil
  keyed_update_elements(updates).each do |k|
    next unless k.populate_allowed?
    submit_process_page_when_page_changes(k)
    before_process_page(k)
    populate_keyword(k)
  end
  @seen_value
end

#verify_dataObject



57
58
59
60
61
# File 'lib/watirmark/controller/controller.rb', line 57

def verify_data
  @verification_errors = []
  keyed_elements.each { |k| verify_keyword(k) if k.verify_allowed? }
  raise Watirmark::VerificationException, @verification_errors.join("\n  ") unless @verification_errors.empty?
end