Class: Rumx::HashBean
Instance Method Summary collapse
- #bean_each_embedded_child(&block) ⇒ Object
-
#bean_find(name_array, index = 0) ⇒ Object
Find the bean.
-
#initialize(hash) ⇒ HashBean
constructor
A new instance of HashBean.
Methods included from Bean
add_root, #bean_add_child, #bean_children, #bean_each, #bean_each_child, #bean_each_child_recursive, #bean_each_operation, #bean_each_operation_recursive, #bean_embedded, #bean_get_and_set_attributes, #bean_get_attributes, #bean_has_attributes?, #bean_has_operations?, #bean_monitor, #bean_remove_child, #bean_set_and_get_attributes, #bean_set_attributes, #bean_synchronize, find, find_operation, included, remove_root, root
Constructor Details
#initialize(hash) ⇒ HashBean
Returns a new instance of HashBean.
5 6 7 |
# File 'lib/rumx/hash_bean.rb', line 5 def initialize(hash) @hash = hash end |
Instance Method Details
#bean_each_embedded_child(&block) ⇒ Object
18 19 20 21 22 |
# File 'lib/rumx/hash_bean.rb', line 18 def (&block) @hash.each do |name, child| yield name, child end end |
#bean_find(name_array, index = 0) ⇒ Object
Find the bean
10 11 12 13 14 15 16 |
# File 'lib/rumx/hash_bean.rb', line 10 def bean_find(name_array, index = 0) return self if index == name_array.size name = name_array[index].to_s child = @hash[name] || @hash[name.to_sym] return nil unless child return child.bean_find(name_array, index+1) end |