Class: ROM::Changeset::Pipe

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(processor = nil) ⇒ Pipe



19
20
21
# File 'lib/rom/repository/changeset/pipe.rb', line 19

def initialize(processor = nil)
  @processor = processor
end

Instance Attribute Details

#processorObject (readonly)

Returns the value of attribute processor.



8
9
10
# File 'lib/rom/repository/changeset/pipe.rb', line 8

def processor
  @processor
end

Class Method Details

.add_timestamps(data) ⇒ Object



10
11
12
13
# File 'lib/rom/repository/changeset/pipe.rb', line 10

def self.add_timestamps(data)
  now = Time.now
  data.merge(created_at: now, updated_at: now)
end

.touch(data) ⇒ Object



15
16
17
# File 'lib/rom/repository/changeset/pipe.rb', line 15

def self.touch(data)
  data.merge(updated_at: Time.now)
end

Instance Method Details

#>>(other) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/rom/repository/changeset/pipe.rb', line 23

def >>(other)
  if processor
    self.class.new(processor >> other)
  else
    self.class.new(other)
  end
end

#call(data) ⇒ Object



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

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