Class: ActiveAdmin::AsyncCount
- Inherits:
-
Object
- Object
- ActiveAdmin::AsyncCount
- Defined in:
- lib/active_admin/async_count.rb
Defined Under Namespace
Classes: NotSupportedError
Instance Method Summary collapse
- #count ⇒ Object (also: #size)
-
#initialize(collection) ⇒ AsyncCount
constructor
A new instance of AsyncCount.
Constructor Details
#initialize(collection) ⇒ AsyncCount
Returns a new instance of AsyncCount.
6 7 8 9 10 11 |
# File 'lib/active_admin/async_count.rb', line 6 def initialize(collection) raise NotSupportedError, "#{collection.inspect} does not support :async_count" unless collection.respond_to?(:async_count) @collection = collection.except(:select, :order) @promise = @collection.async_count end |
Instance Method Details
#count ⇒ Object Also known as: size
13 14 15 16 17 |
# File 'lib/active_admin/async_count.rb', line 13 def count value = @promise.value # value.value due to Rails bug https://github.com/rails/rails/issues/50776 value.respond_to?(:value) ? value.value : value end |