sortifiable 0.2.7 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +5 -0
- data/Rakefile +1 -0
- data/lib/sortifiable.rb +6 -6
- data/lib/sortifiable/version.rb +1 -1
- data/sortifiable.gemspec +1 -0
- metadata +18 -8
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
data/lib/sortifiable.rb
CHANGED
@@ -147,7 +147,7 @@ module Sortifiable
|
|
147
147
|
|
148
148
|
# Return items lower than this item or an empty array if it is the last item
|
149
149
|
def higher_items
|
150
|
-
list_scope.where(["#{quoted_position_column} < ?", current_position]).
|
150
|
+
list_scope.where(["#{quoted_position_column} < ?", current_position]).to_a
|
151
151
|
end
|
152
152
|
|
153
153
|
# Test if this record is in a list
|
@@ -234,7 +234,7 @@ module Sortifiable
|
|
234
234
|
|
235
235
|
# Return items lower than this item or an empty array if it is the last item
|
236
236
|
def lower_items
|
237
|
-
list_scope.where(["#{quoted_position_column} > ?", current_position]).
|
237
|
+
list_scope.where(["#{quoted_position_column} > ?", current_position]).to_a
|
238
238
|
end
|
239
239
|
|
240
240
|
# Swap positions with the next higher item, if one exists.
|
@@ -387,7 +387,7 @@ module Sortifiable
|
|
387
387
|
else
|
388
388
|
update = "#{quoted_position_column} = #{quoted_position_column} - 1"
|
389
389
|
conditions = "#{quoted_position_column} > #{current_position}"
|
390
|
-
list_scope.update_all(update
|
390
|
+
list_scope.where(conditions).update_all(update) > 0
|
391
391
|
end
|
392
392
|
end
|
393
393
|
end
|
@@ -446,7 +446,7 @@ module Sortifiable
|
|
446
446
|
def lock_list! #:nodoc:
|
447
447
|
sql = list_scope.select(list_class.primary_key).lock(true).to_sql
|
448
448
|
column = list_class.columns_hash[list_class.primary_key]
|
449
|
-
connection.select_values(sql).map do |value|
|
449
|
+
list_class.connection.select_values(sql).map do |value|
|
450
450
|
column.type_cast(value)
|
451
451
|
end
|
452
452
|
end
|
@@ -464,7 +464,7 @@ module Sortifiable
|
|
464
464
|
end
|
465
465
|
|
466
466
|
def quoted_position_column #:nodoc:
|
467
|
-
connection.quote_column_name(position_column)
|
467
|
+
list_class.connection.quote_column_name(position_column)
|
468
468
|
end
|
469
469
|
|
470
470
|
def scope_condition #:nodoc:
|
@@ -476,7 +476,7 @@ module Sortifiable
|
|
476
476
|
end
|
477
477
|
|
478
478
|
def update_position(new_position) #:nodoc:
|
479
|
-
base_scope.
|
479
|
+
base_scope.where({ list_class.primary_key => id }).update_all({ position_column => new_position })
|
480
480
|
set_position new_position
|
481
481
|
end
|
482
482
|
end
|
data/lib/sortifiable/version.rb
CHANGED
data/sortifiable.gemspec
CHANGED
@@ -37,6 +37,7 @@ EOF
|
|
37
37
|
|
38
38
|
s.add_dependency "activesupport", ">= 3.0"
|
39
39
|
s.add_dependency "activerecord", ">= 3.0"
|
40
|
+
s.add_development_dependency "appraisal", "~> 0.5"
|
40
41
|
s.add_development_dependency "mysql", ">= 2.8.1"
|
41
42
|
s.add_development_dependency "mysql2", ">= 0.2.7"
|
42
43
|
s.add_development_dependency "pg", ">= 0.9.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sortifiable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '3.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: appraisal
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.5'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.5'
|
46
62
|
- !ruby/object:Gem::Dependency
|
47
63
|
name: mysql
|
48
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,18 +164,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
148
164
|
- - ! '>='
|
149
165
|
- !ruby/object:Gem::Version
|
150
166
|
version: '0'
|
151
|
-
segments:
|
152
|
-
- 0
|
153
|
-
hash: -1709003177613176418
|
154
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
168
|
none: false
|
156
169
|
requirements:
|
157
170
|
- - ! '>='
|
158
171
|
- !ruby/object:Gem::Version
|
159
172
|
version: '0'
|
160
|
-
segments:
|
161
|
-
- 0
|
162
|
-
hash: -1709003177613176418
|
163
173
|
requirements: []
|
164
174
|
rubyforge_project:
|
165
175
|
rubygems_version: 1.8.25
|