lib/rom/repository/changeset/pipe.rb in rom-repository-0.3.1 vs lib/rom/repository/changeset/pipe.rb in rom-repository-1.0.0.beta1
- old
+ new
@@ -1,12 +1,15 @@
require 'transproc/registry'
+require 'transproc/transformer'
module ROM
class Changeset
- class Pipe
+ class Pipe < Transproc::Transformer
extend Transproc::Registry
+ import Transproc::HashTransformations
+
attr_reader :processor
def self.add_timestamps(data)
now = Time.now
data.merge(created_at: now, updated_at: now)
@@ -14,18 +17,22 @@
def self.touch(data)
data.merge(updated_at: Time.now)
end
- def initialize(processor = nil)
+ def initialize(processor = self.class.transproc)
@processor = processor
end
+ def [](name)
+ self.class[name]
+ end
+
def >>(other)
if processor
- self.class.new(processor >> other)
+ Pipe.new(processor >> other)
else
- self.class.new(other)
+ Pipe.new(other)
end
end
def call(data)
if processor