Sha256: 40b10edefe424ca4c88a8f854c5230fe2f4a37c4c89849f769e9ed3c0711dead

Contents?: true

Size: 671 Bytes

Versions: 82

Compression:

Stored size: 671 Bytes

Contents

module ActiveAdmin
  module ScopeChain
    # Scope an ActiveRecord::Relation chain
    #
    # Example:
    #   scope_chain(Scope.new(:published), Article)
    #   # => Article.published
    #
    # @param scope The <ActiveAdmin::Scope> we want to scope on
    # @param chain The ActiveRecord::Relation chain or ActiveRecord::Base class to scope
    # @return <ActiveRecord::Relation or ActiveRecord::Base> The scoped relation chain
    #
    def scope_chain(scope, chain)
      if scope.scope_method
        chain.send(scope.scope_method)
      elsif scope.scope_block
        instance_exec chain, &scope.scope_block
      else
        chain
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 7 rubygems

Version Path
activeadmin-0.6.6 lib/active_admin/helpers/scope_chain.rb
activeadmin-0.6.5 lib/active_admin/helpers/scope_chain.rb
activeadmin-0.6.4 lib/active_admin/helpers/scope_chain.rb
yousty-activeadmin-1.0.4.pre lib/active_admin/helpers/scope_chain.rb
yousty-activeadmin-1.0.3.pre lib/active_admin/helpers/scope_chain.rb
active_administration-0.0.3 lib/active_admin/helpers/scope_chain.rb
activeadministration-0.0.2 lib/active_admin/helpers/scope_chain.rb
active_administration-0.0.2 lib/active_admin/helpers/scope_chain.rb
activeadministration-0.0.1 lib/active_admin/helpers/scope_chain.rb
active_administration-0.0.1 lib/active_admin/helpers/scope_chain.rb
yousty-activeadmin-1.0.2.pre lib/active_admin/helpers/scope_chain.rb
activeadmin-0.6.3 lib/active_admin/helpers/scope_chain.rb
yousty-activeadmin-1.0.1.pre lib/active_admin/helpers/scope_chain.rb
yousty-activeadmin-1.0.0.pre lib/active_admin/helpers/scope_chain.rb
activeadmin-0.6.2 lib/active_admin/helpers/scope_chain.rb
activeadmin-0.6.1 lib/active_admin/helpers/scope_chain.rb
aa-rails4-0.6.0 lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.141 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.136 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.135 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb