Sha256: fc2004c02fa6bac62b5e21da2347f7a7ea3bfb0f914db5dc3b64027e12b13af0

Contents?: true

Size: 677 Bytes

Versions: 43

Compression:

Stored size: 677 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.public_send scope.scope_method
      elsif scope.scope_block
        instance_exec chain, &scope.scope_block
      else
        chain
      end
    end
  end
end

Version data entries

43 entries across 43 versions & 6 rubygems

Version Path
activeadmin-rails-1.7.1 lib/active_admin/helpers/scope_chain.rb
activeadmin-rails-1.7.0 lib/active_admin/helpers/scope_chain.rb
activeadmin-rb-1.6.0 lib/active_admin/helpers/scope_chain.rb
activeadmin-rb-1.5.2 lib/active_admin/helpers/scope_chain.rb
activeadmin-rb-1.5.1 lib/active_admin/helpers/scope_chain.rb
activeadmin-rb-1.5.0 lib/active_admin/helpers/scope_chain.rb
activeadmin-rb-1.4.0 lib/active_admin/helpers/scope_chain.rb
activeadmin-1.4.3 lib/active_admin/helpers/scope_chain.rb
activeadmin-1.4.2 lib/active_admin/helpers/scope_chain.rb
activeadmin-1.4.1 lib/active_admin/helpers/scope_chain.rb
activeadmin-1.4.0 lib/active_admin/helpers/scope_chain.rb
activeadmin-1.3.1 lib/active_admin/helpers/scope_chain.rb
activeadmin-1.3.0 lib/active_admin/helpers/scope_chain.rb
activeadmin-1.2.1 lib/active_admin/helpers/scope_chain.rb
activeadmin_addons-1.1.2 vendor/bundle/ruby/2.3.0/bundler/gems/activeadmin-a5a53c3f2b8f/lib/active_admin/helpers/scope_chain.rb
activeadmin-1.2.0 lib/active_admin/helpers/scope_chain.rb
activeadmin_addons-1.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/lib/active_admin/helpers/scope_chain.rb
yousty-activeadmin-1.0.17.pre lib/active_admin/helpers/scope_chain.rb
yousty-activeadmin-1.0.16.pre lib/active_admin/helpers/scope_chain.rb
activeadmin_addons-1.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/activeadmin-a5a53c3f2b8f/lib/active_admin/helpers/scope_chain.rb