effective_resources 2.8.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 016f2e6e705dc75e0ea58ff2e95f9ce5553122d82a1dd0280ccc327a284b4e93
|
4
|
+
data.tar.gz: eedc423555203163a7c9d3674729c3ab56dd1d69d448d289fef0a0c06bbad3d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 296abe054bdc8e96495d75a2172187b89c093311a5819f7df89c13af90298611673285cec429d96c1a45da88b15e65f0c54e3f0108193f8fdff12117edbf611d
|
7
|
+
data.tar.gz: 6278969a0aefe37f56bae5c036e944ab0d22c7c8142a09127cbfa9b1448be49fd9568b1bb7185db7896f985e85d0594b4864aaa4994d50ba1e0ab2d5590f4326
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#
|
2
|
+
# ActsAsPaginable
|
3
|
+
#
|
4
|
+
# Adds the a `paginate` scope to a model for `limit` and `offset` pagination.
|
5
|
+
#
|
6
|
+
module ActsAsPaginable
|
7
|
+
extend ActiveSupport::Concern
|
8
|
+
|
9
|
+
module Base
|
10
|
+
def acts_as_paginable(options = nil)
|
11
|
+
include ::ActsAsPaginable
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module ClassMethods
|
16
|
+
def acts_as_paginable?; true; end
|
17
|
+
end
|
18
|
+
|
19
|
+
included do
|
20
|
+
def self.default_per_page=(per_page)
|
21
|
+
@default_per_page = per_page
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.default_per_page
|
25
|
+
@default_per_page || 12 # because we often do 3 columns of 4 elements layouts
|
26
|
+
end
|
27
|
+
|
28
|
+
scope :paginate, -> (page: nil, per_page: nil) {
|
29
|
+
per_page = (per_page || default_per_page).to_i
|
30
|
+
page = (page || 1).to_i
|
31
|
+
offset = [(page - 1), 0].max * (per_page).to_i
|
32
|
+
|
33
|
+
all.limit(per_page).offset(offset)
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
@@ -29,8 +29,10 @@ module EffectiveResources
|
|
29
29
|
ActiveRecord::Base.extend(ActsAsTokened::Base)
|
30
30
|
ActiveRecord::Base.extend(ActsAsSlugged::Base)
|
31
31
|
ActiveRecord::Base.extend(ActsAsStatused::Base)
|
32
|
+
ActiveRecord::Base.extend(ActsAsPaginable::Base)
|
32
33
|
ActiveRecord::Base.extend(ActsAsWizard::Base)
|
33
34
|
ActiveRecord::Base.extend(ActsAsPurchasableWizard::Base)
|
35
|
+
|
34
36
|
ActiveRecord::Base.extend(HasManyPurgable::Base)
|
35
37
|
ActiveRecord::Base.extend(HasManyRichTexts::Base)
|
36
38
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_resources
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -159,6 +159,7 @@ files:
|
|
159
159
|
- app/mailers/concerns/effective_mailer.rb
|
160
160
|
- app/models/concerns/acts_as_archived.rb
|
161
161
|
- app/models/concerns/acts_as_email_form.rb
|
162
|
+
- app/models/concerns/acts_as_paginable.rb
|
162
163
|
- app/models/concerns/acts_as_purchasable_wizard.rb
|
163
164
|
- app/models/concerns/acts_as_slugged.rb
|
164
165
|
- app/models/concerns/acts_as_statused.rb
|
@@ -243,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
244
|
- !ruby/object:Gem::Version
|
244
245
|
version: '0'
|
245
246
|
requirements: []
|
246
|
-
rubygems_version: 3.
|
247
|
+
rubygems_version: 3.4.10
|
247
248
|
signing_key:
|
248
249
|
specification_version: 4
|
249
250
|
summary: Make any controller an effective resource controller.
|