Sha256: f9a5504f1742b0efc428a7d252ab0e10762e2d96e9dc62949c1bb3d496c7355c

Contents?: true

Size: 809 Bytes

Versions: 7

Compression:

Stored size: 809 Bytes

Contents

module ActiveAdmin
  class Resource
    module Scopes

      # Return an array of scopes for this resource
      def scopes
        @scopes ||= []
      end

      # Returns a scope for this object by its identifier
      def get_scope_by_id(id)
        id = id.to_s
        scopes.find{|s| s.id == id }
      end

      def default_scope
        @default_scope
      end

      # Create a new scope object for this resource.
      # If you want to internationalize the scope name, you can add
      # to your i18n files a key like "active_admin.scopes.scope_method".
      def scope(*args, &block)
        options = args.extract_options!
        self.scopes << ActiveAdmin::Scope.new(*args, &block)
        if options[:default]
          @default_scope = scopes.last
        end
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
andrewroth_activeadmin-0.3.4 lib/active_admin/resource/scopes.rb
activeadmin-0.3.4 lib/active_admin/resource/scopes.rb
activeadmin-0.3.3 lib/active_admin/resource/scopes.rb
activeadmin-0.3.2 lib/active_admin/resource/scopes.rb
activeadmin-0.3.1 lib/active_admin/resource/scopes.rb
activeadmin-0.3.0 lib/active_admin/resource/scopes.rb
nsm-activeadmin-0.2.2 lib/active_admin/resource/scopes.rb