Class: AutomationObject::BluePrint::HashAdapter::Modal

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

Overview

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

Instance Method Summary collapse

Instance Method Details

#included_viewsArray<Symbol>

Returns array of views this can has

Returns:

  • (Array<Symbol>)

    array of views this can has



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

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



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/automation_object/blue_print/hash_adapter/modal.rb', line 39

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