Class: App::Utils::AppNode
- Inherits:
-
Object
- Object
- App::Utils::AppNode
- Defined in:
- app/concepts/app/utils/app_node.rb
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(app_instance) ⇒ AppNode
constructor
A new instance of AppNode.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(app_instance) ⇒ AppNode
Returns a new instance of AppNode.
12 13 14 15 16 17 18 19 |
# File 'app/concepts/app/utils/app_node.rb', line 12 def initialize(app_instance) @hash = {} @node_start_id = 0 @app_instance = app_instance app_instance.instance_variables.each do |app_instance_var_key| self.instance_variable_set(app_instance_var_key, app_instance.instance_variable_get(app_instance_var_key)) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/concepts/app/utils/app_node.rb', line 21 def method_missing meth, *args, &block begin @app_instance.send(meth, *args, &block) rescue node_id = @node_start_id + 1 @node_start_id = node_id current_node = "#{meth}_#{@node_start_id}" @hash[current_node] = {} @hash[current_node]["component_name"] = meth.to_s @hash[current_node]["config"] = {} @hash[current_node]["argument"] = nil if meth == :page_content @hash[current_node]["components"] = @app_instance.send(:page_nodes) elsif meth == :partial @hash[current_node]["components"] = @app_instance.send(args.first, *args.drop(1)) else if args.first.is_a?(Hash) @hash[current_node]["config"] = args.first else @hash[current_node]["argument"] = args.first end if block_given? @hash[current_node]["components"] = AppNode.build(@app_instance, &block) end end end end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
10 11 12 |
# File 'app/concepts/app/utils/app_node.rb', line 10 def hash @hash end |