Class: OpenStax::Api::V1::AbstractSearchRepresenter

Inherits:
Roar::Decorator
  • Object
show all
Includes:
Roar::Representer::JSON
Defined in:
app/representers/openstax/api/v1/abstract_search_representer.rb

Instance Method Summary collapse

Instance Method Details

#total_countObject



33
34
35
36
37
38
39
40
41
42
43
# File 'app/representers/openstax/api/v1/abstract_search_representer.rb', line 33

def total_count
  return represented[:total_count] if represented[:total_count]
  case represented[:items]
  when ActiveRecord::Relation
    represented[:items].limit(nil).offset(nil).count
  when Array
    represented[:items].count
  else
    1
  end
end