Class: DatastaxRails::GroupedCollection

Inherits:
Hash
  • Object
show all
Defined in:
lib/datastax_rails/grouped_collection.rb

Overview

GroupedCollection extends Hash to add some additional metadata. The hash keys will be the values for the thing that was grouped on. The hash entries point to instances of DatastaxRails::Collection.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#total_entriesFixnum

Returns the total number of entries *in the largest group*. This is to allow will_paginate to work.

Returns:

  • (Fixnum)

    the total number of entries *in the largest group*. This is to allow will_paginate to work.


11
12
13
# File 'lib/datastax_rails/grouped_collection.rb', line 11

def total_entries
  @total_entries
end

#total_for_allFixnum

Returns the total number of entries across all groups that match this search

Returns:

  • (Fixnum)

    the total number of entries across all groups that match this search


11
# File 'lib/datastax_rails/grouped_collection.rb', line 11

attr_accessor :total_entries, :total_groups, :total_for_all

#total_groupsFixnum

Returns the total number of groups if the groups were paginated (not supported yet)

Returns:

  • (Fixnum)

    the total number of groups if the groups were paginated (not supported yet)


11
# File 'lib/datastax_rails/grouped_collection.rb', line 11

attr_accessor :total_entries, :total_groups, :total_for_all

Instance Method Details

#inspectObject


13
14
15
# File 'lib/datastax_rails/grouped_collection.rb', line 13

def inspect
  "<DatastaxRails::GroupedCollection##{object_id} contents: #{super} matching_records #{total_for_all}>"
end