Module: Card::Set::Abstract::Paging::PagingViews::JsonFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb

Instance Method Summary collapse

Instance Method Details

#add_paging_url(hash, page, status) ⇒ Object



106
107
108
109
110
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 106

def add_paging_url hash, page, status
  return unless page && status.in?(%i[next previous])

  hash[status] = path page_link_path_args(page)
end


83
84
85
86
87
88
89
90
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 83

def page_link_path_args page
  {
    limit: limit,
    offset: page * limit,
    item: default_item_view, # hack. need standard voo handling
    format: :json
  }.merge extra_paging_path_args
end

#paging_urls_hashObject



98
99
100
101
102
103
104
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 98

def paging_urls_hash
  hash = {}
  PagingLinks.new(total_pages, current_page).build do |_text, page, status, _options|
    add_paging_url hash, page, status
  end
  hash
end

#view: paging_urlsObject



92
93
94
95
96
# File 'platypus/tmp/set/gem-defaults/mod002-collection/abstract/paging/paging_views.rb', line 92

view :paging_urls, cache: :never do
  return {} unless show_paging?

  { paging: paging_urls_hash }
end