Class: Remont::RecordProcessor
- Inherits:
-
Object
- Object
- Remont::RecordProcessor
- Defined in:
- lib/remont/record_processor.rb
Constant Summary collapse
- NOOP =
proc {}
Instance Method Summary collapse
-
#initialize(schema, before, after) ⇒ RecordProcessor
constructor
A new instance of RecordProcessor.
-
#process!(record) ⇒ ActiveRecord::Base
Record.
Constructor Details
#initialize(schema, before, after) ⇒ RecordProcessor
Returns a new instance of RecordProcessor.
8 9 10 11 12 |
# File 'lib/remont/record_processor.rb', line 8 def initialize(schema, before, after) @schema = schema @before = before || NOOP @after = after || NOOP end |
Instance Method Details
#process!(record) ⇒ ActiveRecord::Base
Returns record.
16 17 18 19 20 21 22 23 24 |
# File 'lib/remont/record_processor.rb', line 16 def process!(record) before.call(record) record.update_columns( # rubocop:disable Rails/SkipsModelValidations processed_attributes(record) ) after.call(record) record end |