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
lalala-4.0.0.dev.134 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.133 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.132 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.131 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.129 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.128 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.126 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.125 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.124 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.123 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.118 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.116 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.114 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.113 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.111 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.109 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.107 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.94 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.92 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb
lalala-4.0.0.dev.90 vendor/deps/active_admin/lib/active_admin/helpers/scope_chain.rb