pandarus 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,18 +31,31 @@ module Pandarus
31
31
  "#{method}:#{path}"
32
32
  end
33
33
 
34
- def page_params_store(method, path, url=@response.env[:next_page])
35
- uri = URI.parse(url)
36
- params = Hash[URI.decode_www_form(uri.query)]
37
- @pagination_params[remember_key(method, path)] = params
34
+ def parse_page_params!(url)
35
+ return nil if url.nil?
36
+ uri = URI.parse url
37
+ Hash[URI.decode_www_form(uri.query)]
38
38
  rescue URI::InvalidURIError
39
39
  nil
40
40
  end
41
41
 
42
+ def page_params_store(method, path, response=@response.env)
43
+ @pagination_params[remember_key(method, path)] = {
44
+ next: parse_page_params!(response[:next_page]),
45
+ current: parse_page_params!(response[:current_page]),
46
+ last: parse_page_params!(response[:last_page])
47
+ }
48
+ end
49
+
42
50
  def page_params_load(method, path)
43
51
  @pagination_params[remember_key(method, path)]
44
52
  end
45
53
 
54
+ def was_last_page?(method, path)
55
+ params = @pagination_params[remember_key(method, path)]
56
+ return false if params.nil? || params[:current].nil? || params[:last].nil?
57
+ return (params[:current] == params[:last])
58
+ end
46
59
 
47
60
  def underscored_merge_opts(opts, base)
48
61
  base.merge(opts).merge(underscored_flatten_hash(opts))
@@ -1,4 +1,4 @@
1
- # This is an autogenerated file. See readme.md har har.
1
+ # This is an autogenerated file. See readme.md.
2
2
  require 'inflecto'
3
3
  require 'virtus'
4
4
  require 'pandarus/models/sis_import_counts'