Class: RedGrape::Pipe::BothPipe

Inherits:
Base show all
Defined in:
lib/red_grape/pipe/both_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, #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
# File 'lib/red_grape/pipe/both_pipe.rb', line 16

def pass(obj, context)
  group =
    if self.opts.empty? or self.opts.first.empty? # TODO なぜかlabelに[]が入ってる
      (obj.out_edges.map(&:target) + obj.in_edges.map(&:source)).uniq
    else
      label = self.opts.first
      out_edges = obj.out_edges.find_all{|e| e.label == label}.map(&:target)
      in_edges = obj.in_edges.find_all{|e| e.label == label}.map(&:source)
      (out_edges + in_edges).uniq
    end
  pass_next context, obj, group
end

#pipe_nameObject



12
13
14
# File 'lib/red_grape/pipe/both_pipe.rb', line 12

def pipe_name
  @opts.empty? ? super : "#{super}(#{@opts.first})"
end