Class: TableSync::Setup::Base
- Inherits:
-
Object
- Object
- TableSync::Setup::Base
- Includes:
- Tainbox
- Defined in:
- lib/table_sync/setup/base.rb
Direct Known Subclasses
Constant Summary collapse
- EVENTS =
%i[create update destroy].freeze
- INVALID_EVENT =
Class.new(StandardError)
- INVALID_CONDITION =
Class.new(StandardError)
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Base
constructor
A new instance of Base.
- #register_callbacks ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Base
Returns a new instance of Base.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/table_sync/setup/base.rb', line 17 def initialize(attrs) super(attrs) self.on = Array.wrap(on).map(&:to_sym) self.if_condition ||= proc { true } self.unless_condition ||= proc { false } raise INVALID_EVENTS unless valid_events? raise INVALID_CONDITION unless valid_conditions? end |
Instance Method Details
#register_callbacks ⇒ Object
29 30 31 |
# File 'lib/table_sync/setup/base.rb', line 29 def register_callbacks applicable_events.each { |event| define_after_commit(event) } end |