Class: AutomationObject::BluePrint::HashAdapter::HookElementRequirements
- Defined in:
- lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb
Overview
Hook Element Requirements-level composite
Instance Attribute Summary
Attributes inherited from Composite
Attributes included from ValidationHelper
Attributes inherited from Composite
#children, #location, #name, #parent
Instance Method Summary collapse
-
#element_blueprints(composite_object = nil) ⇒ AutomationObject::BluePrint::HashAdapter::Element
Convience for getting element blueprints.
-
#element_name ⇒ Symbol
Get name of the element.
-
#hook_order ⇒ Array<Symbol>
Get the order to run the hook in.
-
#requirement(name) ⇒ Object
Get element requirement.
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
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
#element_blueprints(composite_object = nil) ⇒ AutomationObject::BluePrint::HashAdapter::Element
Convience for getting element blueprints
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb', line 48 def element_blueprints(composite_object = nil) composite_object = self unless composite_object # Traverse! return composite_object.elements[element_name] if composite_object.hash[:elements].is_a?(Hash) return element_blueprints(composite_object.parent) if composite_object.parent nil end |
#element_name ⇒ Symbol
Get name of the element
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb', line 35 def element_name element_name = hash[:element_name] case element_name when Symbol, String return element_name.to_sym else return nil end end |
#hook_order ⇒ Array<Symbol>
Get the order to run the hook in
17 18 19 20 21 22 23 24 25 |
# File 'lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb', line 17 def hook_order hook_order = [:exists?] # Always put exists? first hash.each_key do |hook_name| hook_order.push(hook_name) unless %i[element_name exists?].include?(hook_name) end hook_order end |
#requirement(name) ⇒ Object
Get element requirement
29 30 31 |
# File 'lib/automation_object/blue_print/hash_adapter/hook_element_requirements.rb', line 29 def requirement(name) hash[name] ||= nil end |