Sha256: 16529a200c2b81cef5a985e22a1f1b2f54e47a74d25b02c543853a837ff60c9a
Contents?: true
Size: 753 Bytes
Versions: 3
Compression:
Stored size: 753 Bytes
Contents
module Trestle class Scope attr_reader :name, :options, :block def initialize(admin, name, options={}, &block) @admin, @name, @options, @block = admin, name, options, block end def to_param name end def label @options[:label] || I18n.t("admin.scopes.#{name}", default: name.to_s.humanize.titleize) end def default? @options[:default] == true end def apply(collection) if @block @block.call else collection.public_send(name) end end def count(collection) @admin.count(@admin.merge_scopes(collection, apply(@admin.unscope(collection)))) end def active?(params) @admin.scopes_for(params).include?(self) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trestle-0.8.3 | lib/trestle/scope.rb |
trestle-0.8.2 | lib/trestle/scope.rb |
trestle-0.8.0 | lib/trestle/scope.rb |