r_kit 0.5 → 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/r_kit/active_record_utility/active_record_extend.rb +28 -12
  3. data/lib/r_kit/active_record_utility/utilities/series.rb +115 -77
  4. data/lib/r_kit/active_record_utility/utilities/tag.rb +6 -2
  5. data/lib/r_kit/active_record_utility.rb +2 -0
  6. data/lib/r_kit/core/loader.rb +1 -1
  7. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/hr.scss +5 -0
  8. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/links.scss +2 -0
  9. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/paragraphs.scss +3 -1
  10. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography/titles.scss +4 -2
  11. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/base/typography.scss +1 -0
  12. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/components/btn.scss +3 -0
  13. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/alignments.scss +7 -0
  14. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/blocks.scss +4 -0
  15. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/box-shadows/curved-shadows.scss +1 -1
  16. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/box-shadows/straight-shadows.scss +1 -1
  17. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/links.scss +12 -0
  18. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins/titles.scss +6 -10
  19. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/mixins.scss +2 -0
  20. data/lib/r_kit/css/lib/assets/stylesheets/r_kit/variables/colors.scss +1 -1
  21. data/lib/r_kit/css/sass_extend.rb +1 -2
  22. data/lib/r_kit/css.rb +13 -11
  23. data/lib/r_kit/decoration/action_view_base_extend.rb +1 -2
  24. data/lib/r_kit/decoration/base/collection.rb +11 -11
  25. data/lib/r_kit/decoration/base/object.rb +0 -18
  26. data/lib/r_kit/decoration/base.rb +39 -2
  27. data/lib/r_kit/decoration/class.rb +26 -55
  28. data/lib/r_kit/decoration/dsl.rb +14 -83
  29. data/lib/r_kit/decoration/enumerable_extend.rb +5 -1
  30. data/lib/r_kit/decoration/object_extend.rb +5 -0
  31. data/lib/r_kit/decoration.rb +4 -7
  32. data/lib/r_kit/dsl/base/thrust.rb +6 -2
  33. data/lib/r_kit/dsl/base.rb +9 -3
  34. data/lib/r_kit/dsl/dsl_extend.rb +1 -1
  35. data/lib/r_kit/dsl/test.rb +81 -0
  36. data/lib/r_kit/dsl.rb +1 -6
  37. data/lib/r_kit/frame/collection_dsl.rb +24 -0
  38. data/lib/r_kit/frame/empty_frame.rb +7 -0
  39. data/lib/r_kit/frame/instance_dsl.rb +30 -0
  40. data/lib/r_kit/frame.rb +14 -0
  41. data/lib/r_kit/grid/base/grid.rb +69 -19
  42. data/lib/r_kit/grid/base/grid_col.rb +22 -19
  43. data/lib/r_kit/grid/base.rb +1 -15
  44. data/lib/r_kit/grid/binding.rb +3 -10
  45. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid.scss +15 -18
  46. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid_flex.scss +19 -0
  47. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/base/grid_items.scss +5 -0
  48. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/grid.scss +2 -0
  49. data/lib/r_kit/grid/lib/assets/stylesheets/r_kit/mixins/{gris.scss → grid.scss} +0 -0
  50. data/lib/r_kit/grid.rb +2 -3
  51. data/lib/r_kit/override/base.rb +125 -0
  52. data/lib/r_kit/override/method_extend.rb +8 -0
  53. data/lib/r_kit/override/module_extend.rb +53 -0
  54. data/lib/r_kit/override/pattern.rb +53 -0
  55. data/lib/r_kit/override/perfs.rb +117 -0
  56. data/lib/r_kit/override/test.rb +466 -0
  57. data/lib/r_kit/override/unbound_method_extend.rb +8 -0
  58. data/lib/r_kit/override.rb +15 -0
  59. data/lib/r_kit/pagination/base/page.rb +5 -23
  60. data/lib/r_kit/pagination/base.rb +32 -62
  61. data/lib/r_kit/pagination/dsl.rb +10 -0
  62. data/lib/r_kit/pagination/enumerable_extend.rb +7 -0
  63. data/lib/r_kit/pagination.rb +29 -2
  64. data/lib/r_kit/parser/base.rb +19 -0
  65. data/lib/r_kit/parser/leaf.rb +72 -0
  66. data/lib/r_kit/parser/test.rb +76 -0
  67. data/lib/r_kit/parser/tree.rb +22 -0
  68. data/lib/r_kit/parser.rb +8 -0
  69. data/lib/r_kit/struct/collection_delegator.rb +0 -6
  70. data/lib/r_kit/utility/basic_object_extend.rb +9 -0
  71. data/lib/r_kit/utility/kernel_extend.rb +9 -3
  72. data/lib/r_kit/utility/main_extend.rb +22 -0
  73. data/lib/r_kit/utility/module_extend.rb +18 -11
  74. data/lib/r_kit/utility/simple_delegator_extend.rb +1 -1
  75. data/lib/r_kit/utility/symbol_extend.rb +1 -1
  76. data/lib/r_kit/utility.rb +4 -2
  77. data/lib/r_kit/version.rb +1 -1
  78. metadata +29 -5
  79. data/lib/r_kit/grid/base/grid_row.rb +0 -29
  80. data/lib/r_kit/grid/kernel_extend.rb +0 -14
@@ -0,0 +1,466 @@
1
+
2
+ class A
3
+ def x
4
+ "x"
5
+ end
6
+
7
+ override_method :x do
8
+ __olddef__ << "y"
9
+ end
10
+ end
11
+
12
+ # overide classic
13
+ puts "A: xy -> #{ A.new.x }"
14
+
15
+ class B
16
+ def x
17
+ "x"
18
+ end
19
+ end
20
+
21
+ class C < B
22
+ override_method :x do
23
+ __olddef__ << "y"
24
+ end
25
+ end
26
+
27
+ # override w/ inheritance
28
+ puts "C: xy -> #{ C.new.x }"
29
+
30
+ class D
31
+ override_method :x do
32
+ __olddef__ || "y"
33
+ end
34
+ end
35
+
36
+ # override when no previous def
37
+ puts "D: y -> #{ D.new.x }"
38
+
39
+ class E
40
+ def x
41
+ "x"
42
+ end
43
+
44
+ override_method :x do
45
+ __olddef__ << "y"
46
+ end
47
+
48
+ override_methods do
49
+ def x
50
+ __olddef__ << "z"
51
+ end
52
+ end
53
+ end
54
+
55
+ # override many
56
+ puts "E: xyz -> #{ E.new.x }"
57
+
58
+ class F < B
59
+ def a
60
+ "a"
61
+ end
62
+
63
+ override_methods do
64
+ def a
65
+ __olddef__ << "b"
66
+ end
67
+
68
+ def x
69
+ __olddef__ << "y"
70
+ end
71
+ end
72
+ end
73
+
74
+ # multi override don't collapse
75
+ f = F.new
76
+ puts "F: ab -> #{ f.a }"
77
+ puts "F: xy -> #{ f.x }"
78
+ puts "F: ab -> #{ f.a }"
79
+ puts "F: xy -> #{ f.x }"
80
+
81
+
82
+ class G
83
+ def initialize(s)
84
+ @s = s
85
+ end
86
+
87
+ def should?
88
+ @s
89
+ end
90
+
91
+ def x
92
+ "x"
93
+ end
94
+
95
+ depend_pattern = ->{
96
+ if should?
97
+ __newdef__
98
+ else
99
+ nil
100
+ end
101
+ }
102
+
103
+ override_method :x, pattern: depend_pattern do
104
+ __olddef__ << "y"
105
+ end
106
+ end
107
+
108
+ # override w/ depend pattern
109
+ puts "G: -> #{ G.new(false).x }"
110
+ puts "G: xy -> #{ G.new(true).x }"
111
+
112
+ class H
113
+ def x(str)
114
+ "x" << str
115
+ end
116
+
117
+ override_method :x do |str, str_end|
118
+ __olddef__(str) << "y" << str_end
119
+ end
120
+ end
121
+
122
+ # override w/ args
123
+ puts "H: xXyY -> #{ H.new.x('X', 'Y') }"
124
+
125
+ class I
126
+ def x(str)
127
+ "x" << str
128
+ end
129
+
130
+ override_methods do
131
+ def x(str, str_end)
132
+ __olddef__(str) << "y" << str_end
133
+ end
134
+ end
135
+ end
136
+
137
+ # override many w/ args
138
+ puts "I: xXyY -> #{ I.new.x('X', 'Y') }"
139
+
140
+ class J
141
+ def initialize(s)
142
+ @s = s
143
+ end
144
+
145
+ def should?
146
+ @s
147
+ end
148
+
149
+ def x
150
+ "x"
151
+ end
152
+
153
+ if_pattern = ->{
154
+ if should?
155
+ __newdef__
156
+ else
157
+ __olddef__
158
+ end
159
+ }
160
+
161
+ override_method :x, pattern: if_pattern do
162
+ __olddef__ << "y"
163
+ end
164
+ end
165
+
166
+ # override w/ if pattern
167
+ puts "J: x -> #{ J.new(false).x }"
168
+ puts "J: xy -> #{ J.new(true).x }"
169
+
170
+ class K < SimpleDelegator
171
+ override_method :x do
172
+ __olddef__ << "y"
173
+ end
174
+ end
175
+
176
+ # override in delegator
177
+ puts "K: xy -> #{ K.new(B.new).x }"
178
+
179
+ class L
180
+ def initialize
181
+ @should_load = true
182
+ end
183
+
184
+ def load
185
+ "not implemented"
186
+ end
187
+
188
+ override_method :load do
189
+ if @should_load
190
+ @should_load = false
191
+ "load"
192
+ else
193
+ "nothing"
194
+ end
195
+ end
196
+ end
197
+
198
+ # change instance values inside overrided method
199
+ l = L.new
200
+ puts "L: load -> #{ l.load }"
201
+ puts "L: nothing -> #{ l.load }"
202
+
203
+ class M
204
+ def initialize
205
+ @loaded = false
206
+ end
207
+
208
+ def loaded?
209
+ @loaded
210
+ end
211
+
212
+ def load
213
+ "not implemented"
214
+ end
215
+
216
+ override_method :load do
217
+ @loaded = true
218
+ self
219
+ end
220
+ end
221
+
222
+ # return self in overrided method
223
+ puts "M: false -> #{ M.new.loaded? }"
224
+ puts "M: true -> #{ M.new.load.loaded? }"
225
+
226
+ class N
227
+ class << self
228
+ def x
229
+ "x"
230
+ end
231
+
232
+ override_method :x do
233
+ __olddef__ << "y"
234
+ end
235
+ end
236
+ end
237
+
238
+ # override singleton method using '<<' syntax
239
+ puts "N: xy -> #{ N.x }"
240
+
241
+ class O
242
+ def self.x
243
+ "x"
244
+ end
245
+
246
+ override_methods do
247
+ def self.x
248
+ __olddef__ << "y"
249
+ end
250
+ end
251
+ end
252
+
253
+ # override singleton method using 'self.' syntax
254
+ puts "O: xy -> #{ O.x }"
255
+
256
+ class P < SimpleDelegator
257
+ def initialize(obj, should)
258
+ super(obj)
259
+ @should = should
260
+ end
261
+
262
+ if_pattern = ->{
263
+ if @should
264
+ __newdef__
265
+ else
266
+ __olddef__
267
+ end
268
+ }
269
+
270
+ override_method :x, pattern: if_pattern do
271
+ __olddef__ << "y"
272
+ end
273
+ end
274
+
275
+ # override in delegator w/ if pattern
276
+ puts "P: x -> #{ P.new(B.new, false).x }"
277
+ puts "P: xy -> #{ P.new(B.new, true).x }"
278
+
279
+ module Q
280
+ override_method :x do
281
+ __olddef__ << "y" rescue 'hahah'
282
+ end
283
+ end
284
+
285
+ class R
286
+ prepend Q
287
+
288
+ def x
289
+ "x"
290
+ end
291
+ end
292
+
293
+ # override in a prepended module from a class
294
+ puts "R: xy -> #{ (r = R.new).x }"
295
+ puts "R: xy -> #{ r.x }"
296
+
297
+ module S
298
+ def x
299
+ "x"
300
+ end
301
+ end
302
+
303
+ class T
304
+
305
+ override_method :x do
306
+ __olddef__ << "y"
307
+ end
308
+
309
+ include S
310
+
311
+ end
312
+
313
+ # override in a included module from a class
314
+ puts "T: xy -> #{ (t = T.new).x }"
315
+ puts "T: xy -> #{ t.x }"
316
+
317
+ class U < SimpleDelegator
318
+ override_method :x do
319
+ __olddef__ || 'y'
320
+ end
321
+ end
322
+
323
+ # delegate w/ no previous def in delegated object
324
+ puts "U: y -> #{ U.new(Class.new.new).x }"
325
+
326
+ class V
327
+ def self.x
328
+ "x"
329
+ end
330
+
331
+ override_singleton_method :x do
332
+ __olddef__ << "y"
333
+ end
334
+ end
335
+
336
+ # override singleton method w/ specific method
337
+ puts "V: xy -> #{ V.x }"
338
+
339
+ class W
340
+ def self.x
341
+ "x"
342
+ end
343
+
344
+ override_singleton_methods do
345
+ def x
346
+ __olddef__ << "y"
347
+ end
348
+ end
349
+ end
350
+
351
+ # override singleton methods w/ specific method
352
+ puts "W: xy -> #{ W.x }"
353
+
354
+ class X
355
+ def self.x
356
+ "x"
357
+ end
358
+
359
+ override_singleton_method :x do
360
+ __olddef__ << "y"
361
+ end
362
+
363
+ override_singleton_methods do
364
+ def x
365
+ __olddef__ << "z"
366
+ end
367
+ end
368
+ end
369
+
370
+ # override many in singleton
371
+ puts "X: xyz -> #{ X.x }"
372
+
373
+ class Y
374
+ def self.a
375
+ "a"
376
+ end
377
+
378
+ def self.x
379
+ "x"
380
+ end
381
+
382
+ override_singleton_methods do
383
+ def a
384
+ __olddef__ << "b"
385
+ end
386
+
387
+ def x
388
+ __olddef__ << "y"
389
+ end
390
+ end
391
+ end
392
+
393
+ # multi singleton override don't collapse
394
+ puts "Y: ab -> #{ Y.a }"
395
+ puts "Y: xy -> #{ Y.x }"
396
+ puts "Y: ab -> #{ Y.a }"
397
+ puts "Y: xy -> #{ Y.x }"
398
+
399
+
400
+ class Z
401
+ def self.meta_x method_name_1
402
+ singleton_class.send :define_method, method_name_1 do
403
+ # p method_name_1.object_id
404
+ method_name_1
405
+ end
406
+ end
407
+
408
+ override_singleton_method :meta_x do |name|
409
+
410
+ __olddef__(name).tap do |method_name_2|
411
+
412
+ override_singleton_method method_name_2 do
413
+ # p __olddef__.object_id
414
+ __olddef__ << method_name_2.to_s
415
+ end
416
+ end
417
+ end
418
+
419
+ meta_x 'x'
420
+ meta_x 'y'
421
+ meta_x 'z'
422
+
423
+ end
424
+
425
+ # overide nested
426
+ puts "Z: xx -> #{ Z.x }"
427
+ puts "Z: yy -> #{ Z.y }"
428
+ puts "Z: zz -> #{ Z.z }"
429
+ puts "!Z: xx -> #{ Z.x }"
430
+ puts "!Z: yy -> #{ Z.y }"
431
+ puts "!Z: zz -> #{ Z.z }"
432
+ puts "NOTE: this behavior is because `__olddef__' (the nested one) get as a result `method_name_1'"
433
+ puts "NOTE: as `method_name_1' is actually a local variable, it is passed as a reference, so it will be modified"
434
+ puts "NOTE: as `method_name_1' is modified, it will change the behavior of `__olddef__'"
435
+ puts "NOTE: see below a correct implementation of this"
436
+
437
+ class Z2
438
+ def self.meta_x method_name_1
439
+ singleton_class.send :define_method, method_name_1 do
440
+ method_name_1.dup
441
+ end
442
+ end
443
+
444
+ override_singleton_method :meta_x do |name|
445
+
446
+ __olddef__(name).tap do |method_name_2|
447
+
448
+ override_singleton_method method_name_2 do
449
+ __olddef__ << method_name_2.to_s
450
+ end
451
+ end
452
+ end
453
+
454
+ meta_x 'x'
455
+ meta_x 'y'
456
+ meta_x 'z'
457
+
458
+ end
459
+
460
+ # overide nested
461
+ puts "Z: xx -> #{ Z2.x }"
462
+ puts "Z: yy -> #{ Z2.y }"
463
+ puts "Z: zz -> #{ Z2.z }"
464
+ puts "Z: xx -> #{ Z2.x }"
465
+ puts "Z: yy -> #{ Z2.y }"
466
+ puts "Z: zz -> #{ Z2.z }"
@@ -0,0 +1,8 @@
1
+ class UnboundMethod
2
+
3
+ def simple_override receiver:, &block
4
+ name = self.name
5
+ receiver.prepend Module.new{ define_method name, &block }
6
+ end
7
+
8
+ end
@@ -0,0 +1,15 @@
1
+ class RKit::Override
2
+
3
+ load_path __FILE__,
4
+ 'base',
5
+ 'method_extend',
6
+ 'module_extend',
7
+ 'pattern',
8
+ 'unbound_method_extend'
9
+
10
+ # load_path __FILE__, 'test'
11
+ # load_path __FILE__, 'perfs'
12
+
13
+ # TODO: config for 'simple_override' -> active or not ?
14
+
15
+ end
@@ -11,43 +11,25 @@ class RKit::Pagination::Base::Page
11
11
  RKit::Decoration::Dsl.domain self
12
12
  acts_as_decorables do
13
13
 
14
- # TODO: we tried to cancel the underscored alias of __getobj__
15
- # cause the class name is also an attr_name
16
- # but this doesn't work, cause when you use a block, the decorator class creation will be processed after
17
- # so, in decoration, we might whant to alias only if method not already defined
18
- def page
19
- __getobj__.page
20
- end
21
-
22
-
23
14
  after_initialize do
24
- if __getobj__.page == base.page
15
+ if page == base.page
25
16
  alias :page_tag :disabled_link_to_page
26
17
  end
27
18
  end
28
19
 
29
20
 
30
- def page_tag name = __getobj__.page
21
+ def page_tag name = page
31
22
  link_to_page name
32
23
  end
33
24
 
34
25
 
35
- def link_to_page name = __getobj__.page
36
- view.link_to name, view.url_for(page: __getobj__.page), class: :btn
26
+ def link_to_page name = page
27
+ view.link_to name, view.url_for(page: page), class: :btn
37
28
  end
38
29
 
39
- def disabled_link_to_page name = __getobj__.page
30
+ def disabled_link_to_page name = page
40
31
  view.content_tag :span, name, class: :'btn-disabled'
41
32
  end
42
-
43
33
  end
44
34
 
45
-
46
-
47
-
48
- # this need
49
- # current_page
50
-
51
- # and a decorator
52
-
53
35
  end
@@ -12,8 +12,10 @@ class RKit::Pagination::Base < CollectionDelegator
12
12
  @per_page = options[:per_page] || RKit::Pagination.config.per_page[collection.klass]
13
13
  end
14
14
 
15
- tap_attr_accessor :page
16
- tap_attr_accessor :per_page
15
+ def paginated?() true end
16
+
17
+
18
+ tap_attr_accessor :page, :per_page, typecast: :to_i
17
19
 
18
20
  def total_pages
19
21
  (collection.count / per_page.to_f).ceil
@@ -31,17 +33,25 @@ class RKit::Pagination::Base < CollectionDelegator
31
33
 
32
34
 
33
35
  def limited_collection
34
- collection
36
+ @limited_collection ||= collection
35
37
  .limit(per_page)
36
38
  .offset((page-1) * per_page)
37
39
  end
38
40
 
41
+ include Enumerable
42
+
39
43
  def each &block
40
- limited_collection.each &block
44
+ limited_collection.each(&block)
41
45
  end
42
46
 
43
47
  delegate :inspect, to: :limited_collection
44
48
 
49
+ def reverse
50
+ reversed = limited_collection.reverse
51
+ @limited_collection.clear.concat(reversed)
52
+
53
+ self
54
+ end
45
55
 
46
56
 
47
57
  def pages
@@ -62,73 +72,33 @@ class RKit::Pagination::Base < CollectionDelegator
62
72
 
63
73
  RKit::Decoration::Dsl.domain self
64
74
  acts_as_decorables do
75
+ after_initialize do
76
+ # TODO: I need this definition here
77
+ # Otherwise, the base definition in enumerable_extend is found first
65
78
 
66
- include Enumerable
67
-
68
- def each &block
69
- limited_collection.decorate.each &block
79
+ define_singleton_method :paginated?, ->{ true }
70
80
  end
71
81
 
72
82
 
73
- def pagination_tag
74
- view.content_tag :nav, class: :pagination do
75
- [previous_page_tag, pages_tag, next_page_tag].reduce(:safe_concat)
83
+ depend on: :pages do
84
+ def pagination_tag
85
+ view.content_tag :nav, class: :pagination do
86
+ [previous_page_tag, pages_tag, next_page_tag].reduce(:safe_concat)
87
+ end
76
88
  end
77
- end
78
89
 
79
- def previous_page_tag
80
- previous_page.decorate.page_tag "<"
81
- end
90
+ def previous_page_tag
91
+ previous_page.decorate.page_tag "<"
92
+ end
82
93
 
83
- def pages_tag
84
- pages.map(&:decorate).map(&:page_tag).reduce(:safe_concat)
85
- end
94
+ def pages_tag
95
+ pages.map(&:decorate).map(&:page_tag).reduce(:safe_concat)
96
+ end
86
97
 
87
- def next_page_tag
88
- next_page.decorate.page_tag ">"
98
+ def next_page_tag
99
+ next_page.decorate.page_tag ">"
100
+ end
89
101
  end
90
102
  end
91
103
 
92
-
93
-
94
-
95
- # TODO: limited_collection, total_pages & pages can change, based on scopes or "page & per_page" config
96
- # So we need a "@loaded" instance_variable
97
- # that will have the same role as in AR::Relation
98
- # -> either, can't scope if loaded
99
- # -> either, empty the 3 "based on scope/config" variables
100
- # --
101
- # or, we don't memoize the 3 problematic vars
102
- # wich will be my choice right now
103
-
104
-
105
-
106
-
107
- # I need
108
- # collection, records/instances/results/paginated_collection/limited_collection(as we use SQL 'limit')
109
- # current page, total nb items, total pages
110
-
111
- # calling could be : Articles.paginate(page: 2, per_page: 15).published
112
- # note that published is _after_, but we still want to display 15 records
113
- # Alternative call Articles.paginate.page(2).per_page(15)
114
- # --
115
- # the "per_page" will be settable either by an arg in the method,
116
- # or by an option, per model, in the dsl (access by Article.all.instance_variable_get "@klass")
117
- # or in the "pagination" config
118
- # the "current page" will be 1 by default
119
-
120
- # Raise an error if the collection has a "limit" or an "offset" (before or after pagination initialization)
121
- # here is the pagination method scope : Paginator::Collection.new(scoped).limit(per).offset((page-1) * per)
122
-
123
-
124
- # We also need a method "pagination_tag", in the view
125
- # maybe use a decorator to do so.
126
-
127
- # Define an option to use pagination based on instance, in this case, the "per_page" is set to one
128
- # and the "pagination_tag" accept a block to display the "page number"
129
-
130
-
131
- # Idea, the "current_page" info (to disable the current page link) could be an instance of a class (pagination::Page)
132
- # so in that class, (or in her decorator), we could define the "link_to_page" method
133
- # (and the "disabled_link_to", wich we will alias on self)
134
104
  end
@@ -5,11 +5,21 @@ module RKit::Pagination::Dsl
5
5
  method :acts_as_paginables
6
6
  domain ActiveRecord::Base
7
7
 
8
+ params ->(per_page: nil){}
9
+
8
10
  methods :class do
9
11
 
12
+ # TODO: to move in 'before_acts_as_paginables' callback, once this is available in 'dsl'
13
+ if pagination_dsl.params.per_page
14
+ RKit::Pagination.config.per_page[self] = pagination_dsl.params.per_page
15
+ end
16
+
17
+
10
18
  def paginate page: nil, per_page: nil
11
19
  RKit::Pagination::Base.new(all, page: page, per_page: per_page)
12
20
  end
13
21
 
22
+ def paginated?() false end
23
+
14
24
  end
15
25
  end
@@ -0,0 +1,7 @@
1
+ module Enumerable
2
+
3
+ # TODO: paginate method
4
+
5
+ def paginated?() false end
6
+
7
+ end