Sha256: bd2752afce80842b48e0af0911e2b3c68a98275853e6df3b3a1bbda9b680809b

Contents?: true

Size: 889 Bytes

Versions: 45

Compression:

Stored size: 889 Bytes

Contents

module ApiResource
  
  module Callbacks
    
    extend ActiveSupport::Concern
    
    included do
      
      extend ActiveModel::Callbacks
      
      define_model_callbacks :save, :create, :update, :destroy
      
      [:save, :create, :update, :destroy].each do |action|
        alias_method_chain action, :callbacks
      end
      
    end
    
    def save_with_callbacks(*args)
      run_callbacks :save do
        save_without_callbacks(*args)
      end
    end
    
    def create_with_callbacks(*args)
      run_callbacks :create do
        create_without_callbacks(*args)
      end
    end
    
    def update_with_callbacks(*args)
      run_callbacks :update do
        update_without_callbacks(*args)
      end
    end
    
    def destroy_with_callbacks(*args)
      run_callbacks :destroy do
        destroy_without_callbacks(*args)
      end
    end
    
  end
  
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
api_resource-0.6.25 lib/api_resource/callbacks.rb
api_resource-0.6.24 lib/api_resource/callbacks.rb
api_resource-0.6.23 lib/api_resource/callbacks.rb
api_resource-0.6.22 lib/api_resource/callbacks.rb
api_resource-0.6.21 lib/api_resource/callbacks.rb
api_resource-0.6.20 lib/api_resource/callbacks.rb
api_resource-0.6.19 lib/api_resource/callbacks.rb
api_resource-0.6.18 lib/api_resource/callbacks.rb
api_resource-0.6.17 lib/api_resource/callbacks.rb
api_resource-0.6.16 lib/api_resource/callbacks.rb
api_resource-0.6.15 lib/api_resource/callbacks.rb
api_resource-0.6.14 lib/api_resource/callbacks.rb
api_resource-0.6.13 lib/api_resource/callbacks.rb
api_resource-0.6.12 lib/api_resource/callbacks.rb
api_resource-0.6.11 lib/api_resource/callbacks.rb
api_resource-0.6.9 lib/api_resource/callbacks.rb
api_resource-0.6.10 lib/api_resource/callbacks.rb
api_resource-0.6.8 lib/api_resource/callbacks.rb
api_resource-0.6.7 lib/api_resource/callbacks.rb
api_resource-0.6.6 lib/api_resource/callbacks.rb