Sha256: 04ce68a069839f8e7aed0bf8eb7a08901b3345d25613b4f73cbace2fdf7b3fff

Contents?: true

Size: 970 Bytes

Versions: 9

Compression:

Stored size: 970 Bytes

Contents

module ActiveAdmin
  class ResourceController < ::InheritedResources::Base

    module Callbacks
      extend ActiveSupport::Concern
      include ::ActiveAdmin::Callbacks

      included do
        define_active_admin_callbacks :build, :create, :update, :save, :destroy
      end

      protected

      def build_resource
        object = super
        run_build_callbacks object
        object
      end

      def create_resource(object)
        run_create_callbacks object do
          save_resource(object)
        end
      end

      def save_resource(object)
        run_save_callbacks object do
          object.save
        end
      end

      def update_resource(object, attributes)
        object.attributes = attributes
        run_update_callbacks object do
          save_resource(object)
        end
      end

      def destroy_resource(object)
        run_destroy_callbacks object do
          object.destroy
        end
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 4 rubygems

Version Path
andrewroth_activeadmin-0.3.4 lib/active_admin/resource_controller/callbacks.rb
activeadmin-0.3.4 lib/active_admin/resource_controller/callbacks.rb
activeadmin-0.3.3 lib/active_admin/resource_controller/callbacks.rb
activeadmin-0.3.2 lib/active_admin/resource_controller/callbacks.rb
activeadmin-0.3.1 lib/active_admin/resource_controller/callbacks.rb
activeadmin-0.3.0 lib/active_admin/resource_controller/callbacks.rb
nsm-activeadmin-0.2.2 lib/active_admin/resource_controller/callbacks.rb
saulolso-activeadmin-0.2.2.1 lib/active_admin/resource_controller/callbacks.rb
saulolso-activeadmin-0.2.2 lib/active_admin/resource_controller/callbacks.rb