Class: Ditty::Services::PaginationWrapper
- Inherits:
-
Object
- Object
- Ditty::Services::PaginationWrapper
show all
- Defined in:
- lib/ditty/services/pagination_wrapper.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of PaginationWrapper.
6
7
8
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 6
def initialize(list)
@list = list
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
58
59
60
61
62
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 58
def method_missing(method, *args)
return super unless respond_to_missing?(method)
list.send(method, *args)
end
|
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list.
4
5
6
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 4
def list
@list
end
|
Instance Method Details
#current_page_record_range ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 68
def current_page_record_range
if list.respond_to? :current_page_record_range
list.current_page_record_range
else
return (0..0) if list.current_page > page_count
a = 1 + (list.current_page - 1) * page_size
b = a + page_size - 1
b = if b >
a..b
end
end
|
#first_page? ⇒ Boolean
18
19
20
21
22
23
24
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 18
def first_page?
if list.respond_to? :'first_page?'
list.first_page?
else
list.current_page == 0
end
end
|
#last_page? ⇒ Boolean
10
11
12
13
14
15
16
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 10
def last_page?
if list.respond_to? :'last_page?'
list.last_page?
else
list.current_page == list.total_pages
end
end
|
#page_count ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 34
def page_count
if list.respond_to? :page_count
list.page_count
else
list.total_pages
end
end
|
#page_size ⇒ Object
42
43
44
45
46
47
48
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 42
def page_size
if list.respond_to? :page_size
list.page_size
else
list.per_page
end
end
|
50
51
52
53
54
55
56
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 50
def
if list.respond_to? :pagination_record_count
list.
else
list.total_entries
end
end
|
#prev_page ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 26
def prev_page
if list.respond_to? :prev_page
list.prev_page
else
list.previous_page
end
end
|
#respond_to_missing?(method, _include_private = false) ⇒ Boolean
64
65
66
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 64
def respond_to_missing?(method, _include_private = false)
list.respond_to? method
end
|