Class: AutomationObject::BluePrint::HashAdapter::Screen

Inherits:
Composite
  • Object
show all
Defined in:
lib/automation_object/blue_print/hash_adapter/screen.rb

Overview

Screen-level composite, ActiveRecord style composite implementation inheriting from Composite

Instance Method Summary collapse

Instance Method Details

#automatic_modal_changesArray<AutomaticModalChange>

Returns array of AutomaticModalChange that are defined under the screen

Returns:



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/automation_object/blue_print/hash_adapter/screen.rb', line 53

def automatic_modal_changes
  return @automatic_modal_changes if defined? @automatic_modal_changes

  children = hash[:automatic_modal_changes]
  children = children.is_a?(Array) ? children : []
  @automatic_modal_changes = create_array_children(:automatic_modal_changes, children,
                                                   interface: AutomaticModalChange,
                                                   location: location + '[automatic_modal_changes]')

  @automatic_modal_changes
end

#automatic_screen_changesArray<Symbol>

Returns array of screens where screen can automatically change to

Returns:

  • (Array<Symbol>)

    array of screens where screen can automatically change to



66
67
68
69
# File 'lib/automation_object/blue_print/hash_adapter/screen.rb', line 66

def automatic_screen_changes
  screen_array = hash[:automatic_screen_changes] ||= []
  screen_array.map(&:to_sym)
end

#included_viewsArray<Symbol>

Returns array of views this can has

Returns:

  • (Array<Symbol>)

    array of views this can has



72
73
74
75
# File 'lib/automation_object/blue_print/hash_adapter/screen.rb', line 72

def included_views
  included_views_array = hash[:included_views] ||= []
  included_views_array.map(&:to_sym)
end

#merge_viewsObject

Method to take views and merge into this composite



78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/automation_object/blue_print/hash_adapter/screen.rb', line 78

def merge_views
  top_hash = top.hash

  return unless top_hash.is_a?(Hash)
  return unless top_hash[:views].is_a?(Hash)
  top_view_hash = top_hash[:views]

  included_views.each do |included_view|
    next unless top_view_hash[included_view].is_a?(Hash)
    self.hash = hash.deep_merge(top_view_hash[included_view])
  end
end