Class: AutomationObject::BluePrint::HashAdapter::HookAction

Inherits:
Composite show all
Defined in:
lib/automation_object/blue_print/hash_adapter/hook_action.rb

Overview

Hook action composite

Instance Attribute Summary

Attributes inherited from Composite

#hash

Attributes included from ValidationHelper

#errors

Attributes inherited from Composite

#children, #location, #name, #parent

Instance Method Summary collapse

Methods inherited from Composite

#create_array_children, #create_composite, #create_hash_children, #get_child, #get_children, #initialize

Methods included from ValidationHelper

#add_errors, included, #valid?

Methods inherited from Composite

#add_has_many_relationships, #add_has_one_relationships, #get_child, #get_children, has_many, has_many_relationships, has_one, has_one_relationships, #initialize, #top

Methods included from Reflection

#add_alias, #add_attribute

Methods included from CompositeHook

#after_create_run, #before_create_run, included

Constructor Details

This class inherits a constructor from AutomationObject::BluePrint::HashAdapter::Composite

Instance Method Details

#change_screenSymbol?

Returns screen to change to

Returns:

  • (Symbol, nil)

    screen to change to



50
51
52
53
54
55
56
57
58
59
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 50

def change_screen
  change_screen = hash[:change_screen]

  case change_screen
  when Symbol, String
    return change_screen.to_sym
  else
    return nil
  end
end

#change_to_previous_screenBoolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 84

def change_to_previous_screen
  hash[:change_to_previous_screen] ||= false
end

#close_modalBoolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 79

def close_modal
  hash[:close_modal] ||= false
end

#close_screenBoolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 74

def close_screen
  hash[:close_screen] ||= false
end

#empty?Boolean

See if hook actions are empty

Returns:

  • (Boolean)

    if hook actions are empty



45
46
47
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 45

def empty?
  hash.keys.empty?
end

#hook_orderArray<Symbol>

Get the order to run the hook in

Returns:

  • (Array<Symbol>)

    list of hook methods to run in given order



33
34
35
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 33

def hook_order
  hash.keys
end

#lengthInteger

Get length of hook actions

Returns:

  • (Integer)

    length of hook actions



39
40
41
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 39

def length
  hash.keys.length
end

#new_screenSymbol?

Returns new screen

Returns:

  • (Symbol, nil)

    new screen



62
63
64
65
66
67
68
69
70
71
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 62

def new_screen
  new_screen = hash[:new_screen]

  case new_screen
  when Symbol, String
    return new_screen.to_sym
  else
    return nil
  end
end

#possible_screen_changesArray

Returns:

  • (Array)


101
102
103
104
105
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 101

def possible_screen_changes
  return hash[:possible_screen_changes].map(&:to_sym) if hash[:possible_screen_changes].is_a?(Array)

  []
end

#reset_screenBoolean

Returns reset the screen?

Returns:

  • (Boolean)

    reset the screen?



108
109
110
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 108

def reset_screen
  hash[:reset_screen] ||= false
end

#show_modalSymbol?

Returns:

  • (Symbol, nil)


89
90
91
92
93
94
95
96
97
98
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 89

def show_modal
  show_modal = hash[:show_modal]

  case show_modal
  when Symbol, String
    return show_modal.to_sym
  else
    return nil
  end
end

#sleepNumeric

Returns amount of time to sleep

Returns:

  • (Numeric)

    amount of time to sleep



113
114
115
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 113

def sleep
  hash[:sleep] ||= 0
end

#wait_for_elementsArray<HookElementRequirements>

Custom method for array of children instead of Hash

Returns:



119
120
121
122
123
124
125
126
127
128
129
# File 'lib/automation_object/blue_print/hash_adapter/hook_action.rb', line 119

def wait_for_elements
  return @wait_for_elements if defined? @wait_for_elements
  wait_for_elements = hash[:wait_for_elements]

  children = wait_for_elements.is_a?(Array) ? wait_for_elements : []
  @wait_for_elements = create_array_children(:wait_for_elements, children,
                                             interface: HookElementRequirements,
                                             location: location + '[wait_for_elements]')

  @wait_for_elements
end