kaminari-mandatory_ordering 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/lib/kaminari/mandatory_ordering.rb +6 -7
- data/lib/kaminari/mandatory_ordering/active_record_extension.rb +2 -2
- data/lib/kaminari/mandatory_ordering/active_record_model_extension.rb +9 -12
- data/lib/kaminari/mandatory_ordering/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7773e3507b5b8276e9db8cd09c331a8b7bf7bf42
|
4
|
+
data.tar.gz: 17d6fc9277f4babecc5c0ed53a8d96ad222cde77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0aa648e617c73a9c2aa0028d1aa5ac5e8be47f9a48597fdb134b377e2386e081359403fb5de76066bb902be052ff598f32422681d456b336743923a4d7e3e2f
|
7
|
+
data.tar.gz: 68660389c51527d9402ac7532de5676e7d899e9f3c1ea97af78758372ab6649e90a3f59cb68814939e980a735506909e60e5b94382e2b40ec20e5354bceead91
|
data/CHANGELOG.md
ADDED
@@ -1,10 +1,9 @@
|
|
1
1
|
require 'kaminari/mandatory_ordering/version'
|
2
|
-
require '
|
3
|
-
require 'kaminari/mandatory_ordering/active_record_extension'
|
4
|
-
require 'kaminari/mandatory_ordering/configuration'
|
2
|
+
require 'active_support/lazy_load_hooks'
|
5
3
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
ActiveSupport.on_load :active_record do
|
5
|
+
require 'kaminari/mandatory_ordering/error'
|
6
|
+
require 'kaminari/mandatory_ordering/active_record_extension'
|
7
|
+
require 'kaminari/mandatory_ordering/configuration'
|
8
|
+
::ActiveRecord::Base.send :include, Kaminari::MandatoryOrdering::ActiveRecordExtension
|
10
9
|
end
|
@@ -7,14 +7,14 @@ module Kaminari
|
|
7
7
|
|
8
8
|
included do
|
9
9
|
descendants.each do |klass|
|
10
|
-
klass.send(:
|
10
|
+
klass.send(:include, Kaminari::MandatoryOrdering::ActiveRecordModelExtension) if klass.superclass == ::ActiveRecord::Base
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
module ClassMethods
|
15
15
|
def inherited(klass)
|
16
16
|
super
|
17
|
-
klass.send(:
|
17
|
+
klass.send(:include, Kaminari::MandatoryOrdering::ActiveRecordModelExtension) if klass.superclass == ::ActiveRecord::Base
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -2,18 +2,15 @@ module Kaminari
|
|
2
2
|
module MandatoryOrdering
|
3
3
|
module ActiveRecordModelExtension
|
4
4
|
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
else
|
15
|
-
# TODO: Find out why calling `super` fails to find the previously defined method.
|
16
|
-
original.call(number)
|
5
|
+
included do |base|
|
6
|
+
if Kaminari.config.mandatory_ordering
|
7
|
+
orig = base.method(Kaminari.config.page_method_name)
|
8
|
+
base.define_singleton_method(Kaminari.config.page_method_name) do |num = nil|
|
9
|
+
if all.values.fetch(:order, []).none?
|
10
|
+
raise Kaminari::MandatoryOrdering::Error
|
11
|
+
else
|
12
|
+
orig.call(num)
|
13
|
+
end
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaminari-mandatory_ordering
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toms Mikoss
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kaminari
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- ".rspec"
|
134
134
|
- ".rubocop.yml"
|
135
135
|
- ".travis.yml"
|
136
|
+
- CHANGELOG.md
|
136
137
|
- Gemfile
|
137
138
|
- README.md
|
138
139
|
- Rakefile
|
@@ -167,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
version: '0'
|
168
169
|
requirements: []
|
169
170
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.
|
171
|
+
rubygems_version: 2.5.1
|
171
172
|
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: Makes sure ActiveRecord collections paged over by kaminari are ordered
|