Module: Irie::Extensions::Count

Extended by:
ActiveSupport::Concern
Defined in:
lib/irie/extensions/count.rb

Overview

Allowing setting ‘@count` with the count of the records in the index query.

Instance Method Summary collapse

Instance Method Details

#index(options = {}, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/irie/extensions/count.rb', line 12

def index(options={}, &block)
  ::Irie.logger.debug("[Irie] Irie::Extensions::Count.index") if ::Irie.debug?
  return super(options, &block) unless aliased_param_present?(:count)
  @count = collection.count

  ::Irie.logger.debug("[Irie] Irie::Extensions::Count.index: count: #{@count}") if ::Irie.debug?

  result = respond_to?(:autorender_count, true) ? autorender_count(options, &block) : super(options, &block)
  ::Irie.logger.debug("[Irie] Irie::Extensions::Count.index: result: #{result.inspect}") if ::Irie.verbose?
  result
end