Sha256: 57c2801506281fefa6c962c25e97c56c95b34e21121eb5b75e72e20963e0e6b8

Contents?: true

Size: 840 Bytes

Versions: 10

Compression:

Stored size: 840 Bytes

Contents

module Godmin
  module Resources
    module ResourceService
      module BatchActions
        extend ActiveSupport::Concern

        delegate :batch_action_map, to: "self.class"

        def batch_action(action, records)
          if batch_action?(action)
            send("batch_action_#{action}", records)
            true
          else
            false
          end
        end

        def batch_action?(action)
          batch_action_map.key?(action.to_sym)
        end

        module ClassMethods
          def batch_action_map
            @batch_action_map ||= {}
          end

          def batch_action(attr, options = {})
            batch_action_map[attr] = {
              only: nil,
              except: nil,
              confirm: false
            }.merge(options)
          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
godmin-1.2.0 lib/godmin/resources/resource_service/batch_actions.rb
godmin-1.1.0 lib/godmin/resources/resource_service/batch_actions.rb
godmin-1.0.0 lib/godmin/resources/resource_service/batch_actions.rb
godmin-0.12.4 lib/godmin/resources/resource_service/batch_actions.rb
godmin-0.12.3 lib/godmin/resources/resource_service/batch_actions.rb
godmin-0.12.2 lib/godmin/resources/resource_service/batch_actions.rb
godmin-0.12.1 lib/godmin/resources/resource_service/batch_actions.rb
godmin-0.12.0 lib/godmin/resources/resource_service/batch_actions.rb
godmin-0.11.2 lib/godmin/resources/resource_service/batch_actions.rb
godmin-0.11.1 lib/godmin/resources/resource_service/batch_actions.rb