Class: Hospodar::Builder::Strategies::Link

Inherits:
Struct
  • Object
show all
Defined in:
lib/hospodar/builder/strategies/link.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#delegateObject

Returns the value of attribute delegate



6
7
8
# File 'lib/hospodar/builder/strategies/link.rb', line 6

def delegate
  @delegate
end

#objectObject (readonly)

Returns the value of attribute object.



7
8
9
# File 'lib/hospodar/builder/strategies/link.rb', line 7

def object
  @object
end

#step_idObject (readonly)

Returns the value of attribute step_id.



7
8
9
# File 'lib/hospodar/builder/strategies/link.rb', line 7

def step_id
  @step_id
end

#strategyObject

Returns the value of attribute strategy



6
7
8
# File 'lib/hospodar/builder/strategies/link.rb', line 6

def strategy
  @strategy
end

Instance Method Details

#callObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hospodar/builder/strategies/link.rb', line 9

def call
  Enumerator.new do |yielder|
    strategy.call.inject(nil) do |object, (title, layer_object, id)|
      @object = layer_object
      @step_id = id
      if title.nil?
        yielder << [layer_object, id]
        next layer_object
      end
      Hospodar::Builder.def_accessor(title, on: layer_object, to: object, delegate: delegate)
      yielder << [layer_object, id]
      layer_object
    end
  end
end

#last_stepObject



25
26
27
# File 'lib/hospodar/builder/strategies/link.rb', line 25

def last_step
  step_id.title
end