Module: BinnacleAr::Hooks::ClassMethods

Defined in:
lib/binnacle_ar/hooks.rb

Instance Method Summary collapse

Instance Method Details

#binnacle_signal(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/binnacle_ar/hooks.rb', line 6

def binnacle_signal(options = {})
  options[:on] ||= [:create, :update, :destroy]

  options_on = Array(options[:on])

  after_create  :record_create if options_on.include?(:create)
  after_update  :record_update if options_on.include?(:update)
  after_destroy :record_destroy if options_on.include?(:destroy)

  after_initialize do
    @binnacle_client = Binnacle::Client.new(ENV['BINNACLE_API_KEY'], ENV['BINNACLE_API_SECRET'])
  end

  include BinnacleAr::Hooks::InstanceMethods
end