class ActiveRecordImporter::ImportCallbacker

Attributes

callback_methods[R]
object[R]

Public Class Methods

new(object, callback_methods) click to toggle source
# File lib/active_record_importer/import_callbacker.rb, line 5
def initialize(object, callback_methods)
  @object = object
  @callback_methods = callback_methods
end

Public Instance Methods

call() click to toggle source
# File lib/active_record_importer/import_callbacker.rb, line 10
def call
  case callback_methods
    when Array
      run_each_callbacks
    when Symbol
      object.send(callback)
    when Proc
      callback.call(object)
  end
end

Private Instance Methods

run_each_callbacks() click to toggle source
# File lib/active_record_importer/import_callbacker.rb, line 23
def run_each_callbacks
  callback_methods.each do |callback|
    object.send(callback) if callback.is_a?(Symbol)
    callback.call(object) if callback.is_a?(Proc)
  end
end