Class: DatastaxRails::Collection

Inherits:
Array
  • Object
show all
Defined in:
lib/datastax_rails/collection.rb

Overview

Holds a collection of DatastaxRails::Base objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_pageFixnum

Returns the current page of the search that produced these results (used by will_paginate).

Returns:

  • (Fixnum)

    the current page of the search that produced these results (used by will_paginate)



12
# File 'lib/datastax_rails/collection.rb', line 12

attr_accessor :total_entries, :per_page, :current_page, :facets, :highlights

#facetsHash

Returns the facet results (field and/or range).

Returns:

  • (Hash)

    the facet results (field and/or range)



12
# File 'lib/datastax_rails/collection.rb', line 12

attr_accessor :total_entries, :per_page, :current_page, :facets, :highlights

#highlightsObject

Returns the value of attribute highlights.



12
13
14
# File 'lib/datastax_rails/collection.rb', line 12

def highlights
  @highlights
end

#per_pageFixnum

Returns the per page value of the search that produced these results (used by will_paginate).

Returns:

  • (Fixnum)

    the per page value of the search that produced these results (used by will_paginate)



12
# File 'lib/datastax_rails/collection.rb', line 12

attr_accessor :total_entries, :per_page, :current_page, :facets, :highlights

#total_entriesFixnum

Returns the total number of entries that match the search.

Returns:

  • (Fixnum)

    the total number of entries that match the search



12
13
14
# File 'lib/datastax_rails/collection.rb', line 12

def total_entries
  @total_entries
end

Instance Method Details

#inspectObject



14
15
16
# File 'lib/datastax_rails/collection.rb', line 14

def inspect
  "<DatastaxRails::Collection##{object_id} contents: #{super}>"
end

#total_pagesObject



18
19
20
21
# File 'lib/datastax_rails/collection.rb', line 18

def total_pages
  return 1 unless per_page
  (total_entries / per_page.to_f).ceil
end