Class: ActiveRecord::Coders::Pipeline
- Inherits:
-
Object
- Object
- ActiveRecord::Coders::Pipeline
- Defined in:
- lib/active_record/coders/pipeline.rb
Instance Attribute Summary collapse
-
#coders ⇒ Object
readonly
Returns the value of attribute coders.
Instance Method Summary collapse
- #dump(data) ⇒ Object
-
#initialize(*coders) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #load(data) ⇒ Object
Constructor Details
#initialize(*coders) ⇒ Pipeline
Returns a new instance of Pipeline.
5 6 7 |
# File 'lib/active_record/coders/pipeline.rb', line 5 def initialize(*coders) @coders = coders.flatten end |
Instance Attribute Details
#coders ⇒ Object (readonly)
Returns the value of attribute coders.
3 4 5 |
# File 'lib/active_record/coders/pipeline.rb', line 3 def coders @coders end |
Instance Method Details
#dump(data) ⇒ Object
9 10 11 12 13 |
# File 'lib/active_record/coders/pipeline.rb', line 9 def dump(data) coders.inject(data) do |data, coder| coder ? coder.dump(data) : data end end |
#load(data) ⇒ Object
15 16 17 18 19 |
# File 'lib/active_record/coders/pipeline.rb', line 15 def load(data) coders.reverse.inject(data) do |data, coder| coder ? coder.load(data) : data end end |