Class: Oedipus::DataMapper::Collection

Inherits:
DataMapper::Collection
  • Object
show all
Defined in:
lib/oedipus/data_mapper/collection.rb

Overview

Adds some additional methods to DataMapper::Collection to provide meta data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query, records = nil, options = {}) ⇒ Collection

Initialize a new Collection for the given query and records.

Parameters:

  • query (DataMapper::Query)

    a query contructed to search for records with a set of ids

  • records (Array) (defaults to: nil)

    a pre-loaded collection of records used to hydrate models

  • [Integer] (Hash)

    a customizable set of options

  • [Hash] (Hash)

    a customizable set of options



40
41
42
43
44
45
46
47
48
49
# File 'lib/oedipus/data_mapper/collection.rb', line 40

def initialize(query, records = nil, options = {})
  super(query, records)
  @time        = options[:time]
  @total_found = options[:total_found]
  @count       = options[:count]
  @keywords    = options[:keywords]
  @docs        = options[:docs]
  @facets      = options.fetch(:facets, {})
  @pager       = options[:pager]
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



16
17
18
# File 'lib/oedipus/data_mapper/collection.rb', line 16

def count
  @count
end

#docsObject (readonly)

Returns the value of attribute docs.



19
20
21
# File 'lib/oedipus/data_mapper/collection.rb', line 19

def docs
  @docs
end

#facetsObject (readonly)

Returns the value of attribute facets.



17
18
19
# File 'lib/oedipus/data_mapper/collection.rb', line 17

def facets
  @facets
end

#keywordsObject (readonly)

Returns the value of attribute keywords.



18
19
20
# File 'lib/oedipus/data_mapper/collection.rb', line 18

def keywords
  @keywords
end

#timeObject (readonly)

Returns the value of attribute time.



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

def time
  @time
end

#total_foundObject (readonly)

Returns the value of attribute total_found.



15
16
17
# File 'lib/oedipus/data_mapper/collection.rb', line 15

def total_found
  @total_found
end