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

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod006-card-mod-collection/abstract/paging/paging_views.rb,
card/tmpsets/set/mod005-card-mod-collection/abstract/paging/paging_views.rb

Instance Method Summary collapse

Instance Method Details

#add_paging_url(hash, page, status) ⇒ Object



113
114
115
116
117
# File 'card/tmpsets/set/mod006-card-mod-collection/abstract/paging/paging_views.rb', line 113

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

  hash[status] = path page_link_path_args(page)
end


90
91
92
93
94
95
96
97
# File 'card/tmpsets/set/mod006-card-mod-collection/abstract/paging/paging_views.rb', line 90

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



105
106
107
108
109
110
111
# File 'card/tmpsets/set/mod006-card-mod-collection/abstract/paging/paging_views.rb', line 105

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



99
100
101
102
103
# File 'card/tmpsets/set/mod006-card-mod-collection/abstract/paging/paging_views.rb', line 99

view :paging_urls, cache: :never do
  return {} unless total_pages > 1

  { paging: paging_urls_hash }
end