Class: AngryMob::Node
- Includes:
- Log
- Defined in:
- lib/angry_mob/node.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#name ⇒ Object
Returns the value of attribute name.
-
#resource_locator ⇒ Object
Returns the value of attribute resource_locator.
Instance Method Summary collapse
- #__consolidate_hash(hash, seen) ⇒ Object
- #consolidate! ⇒ Object
-
#initialize(name, attributes) ⇒ Node
constructor
A new instance of Node.
- #merge_defaults!(attrs) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #setup_finished! ⇒ Object
Methods included from Log
#__class_to_s, #__class_to_s!, #debug, #log
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
40 41 42 |
# File 'lib/angry_mob/node.rb', line 40 def method_missing(method,*args,&block) attributes.__send__(method,*args) end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes
2 3 4 |
# File 'lib/angry_mob/node.rb', line 2 def attributes @attributes end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/angry_mob/node.rb', line 2 def name @name end |
#resource_locator ⇒ Object
Returns the value of attribute resource_locator
2 3 4 |
# File 'lib/angry_mob/node.rb', line 2 def resource_locator @resource_locator end |
Instance Method Details
#__consolidate_hash(hash, seen) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/angry_mob/node.rb', line 25 def __consolidate_hash(hash,seen) return if seen.key?(hash) seen[hash] = true hash.each do |key,value| case value when Hash __consolidate_hash(value,seen) when Proc hash[key] = value[self] end end end |
#consolidate! ⇒ Object
19 20 21 22 |
# File 'lib/angry_mob/node.rb', line 19 def consolidate! node = self __consolidate_hash(attributes,{}) end |
#merge_defaults!(attrs) ⇒ Object
10 11 12 13 |
# File 'lib/angry_mob/node.rb', line 10 def merge_defaults!(attrs) puts "merging defaults" attributes.reverse_deep_merge!(attrs) end |
#setup_finished! ⇒ Object
15 16 17 |
# File 'lib/angry_mob/node.rb', line 15 def setup_finished! self.resource_locator ||= AngryMob::Target::DefaultResourceLocator.new end |