Sha256: 9a47063a196eb3077aa6767f5a373365b2e02b5fe3570ec7ef6d6898e671c80e

Contents?: true

Size: 673 Bytes

Versions: 1

Compression:

Stored size: 673 Bytes

Contents

module ActiveManageable
  module Methods
    module Edit
      extend ActiveSupport::Concern

      included do
        include ActiveManageable::Methods::Auxiliary::Includes
        include ActiveManageable::Methods::Auxiliary::Select
      end

      def edit(id:, options: {})
        initialize_state(options: options)

        @target = action_scope
        includes(@options[:includes])
        select(@options[:select])

        yield if block_given?

        @target = find_object_for_edit(id: id)
        authorize(record: @target)

        @target
      end

      private

      def find_object_for_edit(id:)
        @target.find(id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_manageable-0.2.0 lib/active_manageable/methods/edit.rb