sortability 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sortability/active_record/base.rb +9 -9
- data/lib/sortability/version.rb +1 -1
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +2276 -4011
- data/spec/lib/sortability/active_record/connection_adapters/table_definition_spec.rb +1 -1
- metadata +52 -48
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -140
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e811a6edc06dbfee9c4432f0b81eec7a36aec4cf07e40e5604f397f84a62007f
|
4
|
+
data.tar.gz: 172646fbe4de26f3def8354d671378a9fc5d6faea2b95757d0973c06c6e9de43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6844492fe3c495616404aa9cf5edcda32fd8082d6c3a515f706e2b64710a9e8cc459c5845647d26ab8b9f65599af332bc56c085f0cae670072fddd8293cdfadb
|
7
|
+
data.tar.gz: 118dd54f18ad0de05bab919d8f65dddeb0de04861fdb1b3be819ca57fce7b4b00a71531e407f3c37299ca19a293154d497c752293c7ba8093144be1a4f98f67e
|
@@ -126,24 +126,24 @@ module Sortability
|
|
126
126
|
end
|
127
127
|
|
128
128
|
# Defines a sortable has_many relation on the container
|
129
|
-
def sortable_has_many(records, scope_or_options = nil,
|
130
|
-
scope, options = extract_association_params(scope_or_options,
|
129
|
+
def sortable_has_many(records, scope_or_options = nil, **remaining_options, &extension)
|
130
|
+
scope, options = extract_association_params(scope_or_options, remaining_options)
|
131
131
|
if scope.nil?
|
132
132
|
on = options[:on] || :sort_position
|
133
133
|
scope = -> { order(on) }
|
134
134
|
end
|
135
135
|
|
136
|
-
class_exec { has_many records, scope, options.except(:on), &extension }
|
136
|
+
class_exec { has_many records, scope, **options.except(:on), &extension }
|
137
137
|
end
|
138
138
|
|
139
139
|
# Defines a sortable belongs_to relation on the child records
|
140
140
|
def sortable_belongs_to(container, scope_or_options = nil,
|
141
|
-
|
142
|
-
scope, options = extract_association_params(scope_or_options,
|
141
|
+
**remaining_options, &extension)
|
142
|
+
scope, options = extract_association_params(scope_or_options, remaining_options)
|
143
143
|
on = options[:on] || :sort_position
|
144
144
|
|
145
145
|
class_exec do
|
146
|
-
belongs_to container, scope, options.except(:on, :scope), &extension
|
146
|
+
belongs_to container, scope, **options.except(:on, :scope), &extension
|
147
147
|
|
148
148
|
reflection = reflect_on_association(container)
|
149
149
|
options[:scope] ||= reflection.polymorphic? ? \
|
@@ -181,11 +181,11 @@ module Sortability
|
|
181
181
|
|
182
182
|
protected
|
183
183
|
|
184
|
-
def extract_association_params(scope_or_options,
|
184
|
+
def extract_association_params(scope_or_options, remaining_options)
|
185
185
|
if scope_or_options.is_a?(Hash)
|
186
|
-
[nil, scope_or_options]
|
186
|
+
[nil, scope_or_options.merge(remaining_options)]
|
187
187
|
else
|
188
|
-
[scope_or_options,
|
188
|
+
[scope_or_options, remaining_options]
|
189
189
|
end
|
190
190
|
end
|
191
191
|
end
|
data/lib/sortability/version.rb
CHANGED
data/spec/dummy/db/test.sqlite3
CHANGED
Binary file
|