Class: RedGrape::Pipe::PathPipe

Inherits:
Base show all
Defined in:
lib/red_grape/pipe/path_pipe.rb

Instance Attribute Summary

Attributes inherited from Base

#it, #next, #opts, #prev, #value

Instance Method Summary collapse

Methods inherited from Base

#copy, #done?, #dup, #first?, #first_pipe, #initialize, #last?, #method_missing, #pass_next, #pipe_eval, #pipe_name, #size, #take, #to_a, #to_ary, #to_s

Constructor Details

This class inherits a constructor from RedGrape::Pipe::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RedGrape::Pipe::Base

Instance Method Details

#pass(obj, context) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/red_grape/pipe/path_pipe.rb', line 16

def pass(obj, context)
  context.push_history obj do |ctx|
    history = ctx.history.dup
    if self.opts.empty?
      PathGroup.new history
    else
      ary = []
      history.each_with_index do |h, index|
        prc = self.opts[index]
        if prc
          context.it = h
          ary << context.eval(&prc)
        else
          ary << h
        end
      end 
      PathGroup.new ary
    end
  end
end