cowtech-rails 1.9.7.5 → 1.9.7.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,83 +7,88 @@
|
|
7
7
|
module Cowtech
|
8
8
|
module RubyOnRails
|
9
9
|
module Models
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
if defined?(ActiveRecord) then
|
11
|
+
class ModelBase < ::ActiveRecord::Base
|
12
|
+
def self.deleted_column
|
13
|
+
"deleted_at"
|
14
|
+
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
def self.status_column
|
17
|
+
"status_id"
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def self.deleted_status_id
|
21
|
+
0
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
def self.[](what, only_id = false)
|
25
|
+
self.__finalize(self.__safe_index_find(what), only_id)
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
def safe_id
|
29
|
+
if self.id then self.id else 0 end
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def editable?(user = nil)
|
33
|
+
true
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def deletable?(user = nil)
|
37
|
+
true
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
40
|
+
def delete(definitive = false)
|
41
|
+
if !definitive then
|
42
|
+
if self.deletable? then
|
43
|
+
if self.has_attribute?(self.class.deleted_column) then
|
44
|
+
self.update_attribute(self.class.deleted_column, DateTime.now)
|
45
|
+
true
|
46
|
+
elsif self.has_attribute?(self.class.status_column) then
|
47
|
+
self.update_attribute(self.class.status_column, self.deleted_status)
|
48
|
+
true
|
49
|
+
else
|
50
|
+
super()
|
51
|
+
end
|
48
52
|
else
|
49
|
-
|
53
|
+
false
|
50
54
|
end
|
51
55
|
else
|
52
|
-
|
56
|
+
super()
|
53
57
|
end
|
54
|
-
else
|
55
|
-
super()
|
56
58
|
end
|
57
|
-
end
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
def self.__index_find(what)
|
65
|
-
self.find(what)
|
60
|
+
def is?(other)
|
61
|
+
other ? (self.id == self.class.__safe_index_find(other).id) : false
|
66
62
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
else
|
72
|
-
nil
|
63
|
+
|
64
|
+
private
|
65
|
+
def self.__index_find(what)
|
66
|
+
self.find(what)
|
73
67
|
end
|
74
|
-
end
|
75
68
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
69
|
+
def self.__finalize(record, only_id = false)
|
70
|
+
if record then
|
71
|
+
only_id ? record.id : record
|
72
|
+
else
|
73
|
+
nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.__safe_index_find(what)
|
82
78
|
record = nil
|
83
|
-
|
79
|
+
|
80
|
+
begin
|
81
|
+
record = self.__index_find(what)
|
82
|
+
rescue ActiveRecord::RecordNotFound
|
83
|
+
record = nil
|
84
|
+
end
|
84
85
|
|
85
|
-
|
86
|
-
|
86
|
+
record
|
87
|
+
end
|
88
|
+
end
|
89
|
+
else
|
90
|
+
class ModelBase
|
91
|
+
end
|
87
92
|
end
|
88
93
|
end
|
89
94
|
end
|
data/lib/cowtech/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cowtech-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.7.
|
4
|
+
version: 1.9.7.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cowtech-extensions
|
16
|
-
requirement: &
|
16
|
+
requirement: &70126381000440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70126381000440
|
25
25
|
description: A general purpose Rails utility plugin.
|
26
26
|
email: shogun_panda@me.com
|
27
27
|
executables: []
|