Class: ROM::Changeset::Pipe Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/repository/changeset/pipe.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Composable data transformation pipe used by default in changesets

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processor = self.class.transproc) ⇒ Pipe

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Pipe.



30
31
32
# File 'lib/rom/repository/changeset/pipe.rb', line 30

def initialize(processor = self.class.transproc)
  @processor = processor
end

Instance Attribute Details

#processorObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



28
29
30
# File 'lib/rom/repository/changeset/pipe.rb', line 28

def processor
  @processor
end

Class Method Details

.[](name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



34
35
36
# File 'lib/rom/repository/changeset/pipe.rb', line 34

def self.[](name)
  container[name]
end

Instance Method Details

#>>(other) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



50
51
52
53
54
55
56
# File 'lib/rom/repository/changeset/pipe.rb', line 50

def >>(other)
  if processor
    Pipe.new(processor >> other)
  else
    Pipe.new(other)
  end
end

#[](name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



38
39
40
# File 'lib/rom/repository/changeset/pipe.rb', line 38

def [](name)
  self.class[name]
end

#bind(context) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
46
47
48
# File 'lib/rom/repository/changeset/pipe.rb', line 42

def bind(context)
  if processor.is_a?(Proc)
    self.class.new(Pipe[-> *args { context.instance_exec(*args, &processor) }])
  else
    self
  end
end

#call(data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



58
59
60
61
62
63
64
# File 'lib/rom/repository/changeset/pipe.rb', line 58

def call(data)
  if processor
    processor.call(data)
  else
    data
  end
end