Class: Gloo::Objs::EachChild

Inherits:
Object
  • Object
show all
Defined in:
lib/gloo/objs/ctrl/each_child.rb

Constant Summary collapse

CHILD =
'child'.freeze
IN =
'IN'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(engine, iterator_obj) ⇒ EachChild


Create Iterator



18
19
20
21
# File 'lib/gloo/objs/ctrl/each_child.rb', line 18

def initialize( engine, iterator_obj )
  @engine = engine
  @iterator_obj = iterator_obj
end

Class Method Details

.use_for?(iterator_obj) ⇒ Boolean

Use this iterator for each loop?

Returns:



31
32
33
34
35
# File 'lib/gloo/objs/ctrl/each_child.rb', line 31

def self.use_for?( iterator_obj )
  return true if iterator_obj.find_child CHILD

  return false
end

Instance Method Details

#runObject

Run for each child.



45
46
47
48
49
50
51
52
53
54
# File 'lib/gloo/objs/ctrl/each_child.rb', line 45

def run
  o = @iterator_obj.find_child IN
  return unless o

  o = Gloo::Objs::Alias.resolve_alias( @engine, o )
  o.children.each do |child|
    set_child child
    @iterator_obj.run_do
  end
end

#set_child(obj) ⇒ Object

Set the child alias.



59
60
61
62
63
64
# File 'lib/gloo/objs/ctrl/each_child.rb', line 59

def set_child( obj )
  o = @iterator_obj.find_child CHILD
  return unless o

  o.set_value obj.pn
end