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.
8
9
10
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 8
def initialize(list)
@list = list
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
60
61
62
63
64
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 60
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.
6
7
8
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 6
def list
@list
end
|
Instance Method Details
#current_page_record_range ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 70
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
20
21
22
23
24
25
26
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 20
def first_page?
if list.respond_to? :'first_page?'
list.first_page?
else
list.current_page == 0
end
end
|
#last_page? ⇒ Boolean
12
13
14
15
16
17
18
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 12
def last_page?
if list.respond_to? :'last_page?'
list.last_page?
else
list.current_page == list.total_pages
end
end
|
#page_count ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 36
def page_count
if list.respond_to? :page_count
list.page_count
else
list.total_pages
end
end
|
#page_size ⇒ Object
44
45
46
47
48
49
50
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 44
def page_size
if list.respond_to? :page_size
list.page_size
else
list.per_page
end
end
|
52
53
54
55
56
57
58
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 52
def
if list.respond_to? :pagination_record_count
list.
else
list.total_entries
end
end
|
#prev_page ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 28
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
66
67
68
|
# File 'lib/ditty/services/pagination_wrapper.rb', line 66
def respond_to_missing?(method, _include_private = false)
list.respond_to? method
end
|