Class: Fera::Collection

Inherits:
ActiveResource::Collection
  • Object
show all
Defined in:
lib/fera/models/collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsed = {}) ⇒ Collection

Returns a new instance of Collection.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fera/models/collection.rb', line 7

def initialize(parsed = {})
  super(parsed['data'])
  @result_count = parsed['result_count']
  @total_count = parsed['total_count']

  @using_pagination = parsed.key?('page')

  if @using_pagination
    @page = parsed['page']
    @total_pages = parsed['total_pages']
    @page_size = parsed['page_size']
  else
    @offset = parsed['offset']
    @limit = parsed['limit']
  end
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



5
6
7
# File 'lib/fera/models/collection.rb', line 5

def limit
  @limit
end

#offsetObject (readonly)

Returns the value of attribute offset.



5
6
7
# File 'lib/fera/models/collection.rb', line 5

def offset
  @offset
end

#pageObject (readonly)

Returns the value of attribute page.



5
6
7
# File 'lib/fera/models/collection.rb', line 5

def page
  @page
end

#page_sizeObject (readonly)

Returns the value of attribute page_size.



5
6
7
# File 'lib/fera/models/collection.rb', line 5

def page_size
  @page_size
end

#result_countObject (readonly)

Returns the value of attribute result_count.



5
6
7
# File 'lib/fera/models/collection.rb', line 5

def result_count
  @result_count
end

#total_countObject (readonly)

Returns the value of attribute total_count.



5
6
7
# File 'lib/fera/models/collection.rb', line 5

def total_count
  @total_count
end

#total_pagesObject (readonly)

Returns the value of attribute total_pages.



5
6
7
# File 'lib/fera/models/collection.rb', line 5

def total_pages
  @total_pages
end

Instance Method Details

#using_pagination?Boolean

Returns:

  • (Boolean)


24
# File 'lib/fera/models/collection.rb', line 24

def using_pagination?; @using_pagination; end