ar-orderable 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ar-orderable.gemspec +1 -1
- data/lib/ar-orderable.rb +10 -6
- metadata +4 -8
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eef4d72d4d551698488cc09c1f8c3f61aa18d0d0
|
4
|
+
data.tar.gz: 081e3058c8877e0c493b5835dd8bb3950df096cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc0a587b1a6bf201eadeaed343ef9cc8860aba707a9cf77f050ab3a590a49794e32140cc738c77c34084845221d2c81b24a5518637110c738689b1b7d9e500c7
|
7
|
+
data.tar.gz: ab8cf47b4a991fe8cf1b04aa9bb736646ec460401598d0c43422ceb594aed5e2682fba899c0c08ca4ca605fe3e5e421dbba247eead3dbb546c62a5a2619e74e8
|
data/ar-orderable.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ar-orderable"
|
6
|
-
s.version = '1.0.
|
6
|
+
s.version = '1.0.5'
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.authors = ["ITHouse (Latvia)", "Gatis Tomsons"]
|
9
9
|
s.email = "support@ithouse.lv"
|
data/lib/ar-orderable.rb
CHANGED
@@ -22,8 +22,13 @@ module ActiveRecord
|
|
22
22
|
include ActiveRecord::Orderable::InstanceMethods
|
23
23
|
else
|
24
24
|
msg = "[IMPORTANT] ActiveRecord::Orderable plugin: class #{self} has missing column '#{self.orderable_column}'"
|
25
|
-
|
26
|
-
|
25
|
+
if defined?(RAILS_DEFAULT_LOGGER)
|
26
|
+
RAILS_DEFAULT_LOGGER.error msg
|
27
|
+
elsif defined?(Rails.logger)
|
28
|
+
Rails.logger.error msg
|
29
|
+
elsif Rails.env == "development"
|
30
|
+
puts msg
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
@@ -47,7 +52,7 @@ module ActiveRecord
|
|
47
52
|
end
|
48
53
|
|
49
54
|
module InstanceMethods
|
50
|
-
|
55
|
+
|
51
56
|
# Moves Item to given position
|
52
57
|
def move_to nr, options = {}
|
53
58
|
if options[:skip_callbacks].nil? ? self.class.skip_callbacks_for_orderable : options[:skip_callbacks]
|
@@ -79,7 +84,6 @@ module ActiveRecord
|
|
79
84
|
|
80
85
|
def pre_save_ordering
|
81
86
|
column_name = self.class.orderable_column
|
82
|
-
|
83
87
|
self[column_name] = 0 if self[column_name].nil?
|
84
88
|
if self.id
|
85
89
|
if self[column_name] == 0
|
@@ -91,7 +95,7 @@ module ActiveRecord
|
|
91
95
|
else
|
92
96
|
self[column_name] = self.all_orderable.count + 1 if self[column_name].to_i == 0
|
93
97
|
end
|
94
|
-
|
98
|
+
|
95
99
|
return unless self.all_orderable.where("id != ? and #{column_name} = ?", self.id, self[column_name]).count > 0
|
96
100
|
self.all_orderable.where("#{self.class.table_name}.id != ?",self.id || 0).each do |item|
|
97
101
|
item[column_name] = 0 if item[column_name].nil?
|
@@ -105,7 +109,7 @@ module ActiveRecord
|
|
105
109
|
item[column_name] += 1
|
106
110
|
end
|
107
111
|
end
|
108
|
-
|
112
|
+
|
109
113
|
if item[column_name] != item.send("#{column_name}_was")
|
110
114
|
self.class.raw_orderable_update(item.id, item[column_name])
|
111
115
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar-orderable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ITHouse (Latvia)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -46,7 +46,6 @@ files:
|
|
46
46
|
- MIT-LICENSE
|
47
47
|
- README.md
|
48
48
|
- Rakefile
|
49
|
-
- VERSION
|
50
49
|
- ar-orderable.gemspec
|
51
50
|
- lib/ar-orderable.rb
|
52
51
|
- spec/ar-orderable_spec.rb
|
@@ -72,11 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
71
|
version: '0'
|
73
72
|
requirements: []
|
74
73
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.0.
|
74
|
+
rubygems_version: 2.0.7
|
76
75
|
signing_key:
|
77
76
|
specification_version: 4
|
78
77
|
summary: You can order AR records and skip callbacks
|
79
|
-
test_files:
|
80
|
-
- spec/ar-orderable_spec.rb
|
81
|
-
- spec/spec.opts
|
82
|
-
- spec/spec_helper.rb
|
78
|
+
test_files: []
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.0.3
|