Class: PaginatedSerializer::Serializer

Inherits:
Object
  • Object
show all
Defined in:
lib/paginated_serializer/serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection) ⇒ Serializer

Returns a new instance of Serializer.



8
9
10
# File 'lib/paginated_serializer/serializer.rb', line 8

def initialize(collection)
  @collection = collection
end

Instance Attribute Details

#collectionObject

Returns the value of attribute collection.



6
7
8
# File 'lib/paginated_serializer/serializer.rb', line 6

def collection
  @collection
end

Instance Method Details

#to_jsonObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/paginated_serializer/serializer.rb', line 12

def to_json
  {
    per_page: per_page,
    total: total,
    total_pages: total_pages,
    last_page: last_page,
    current_page: current_page,
    first_page: first_page,
    next_page: next_page,
    previous_page: previous_page
  }.merge(collection_json)
end