Class: Rumx::ListBean

Inherits:
Object
  • Object
show all
Includes:
Bean
Defined in:
lib/rumx/list_bean.rb

Instance Method Summary collapse

Methods included from Bean

#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_attribute, find_operation, included, root

Constructor Details

#initialize(list) ⇒ ListBean

Returns a new instance of ListBean.



5
6
7
# File 'lib/rumx/list_bean.rb', line 5

def initialize(list)
  @list = list
end

Instance Method Details

#bean_each_embedded_child(&block) ⇒ Object



19
20
21
22
23
# File 'lib/rumx/list_bean.rb', line 19

def bean_each_embedded_child(&block)
  @list.each_with_index do |child, i|
    yield i, child
  end
end

#bean_find(name_array, index = 0) ⇒ Object

Find the bean



10
11
12
13
14
15
16
17
# File 'lib/rumx/list_bean.rb', line 10

def bean_find(name_array, index = 0)
  return self if index == name_array.size
  name = name_array[index]
  return nil unless name.match(/^\d+$/)
  child = @list[name.to_i]
  return nil unless child
  return child.bean_find(name_array, index+1)
end