cowtech-rails 1.9.7.5 → 1.9.7.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,83 +7,88 @@
7
7
  module Cowtech
8
8
  module RubyOnRails
9
9
  module Models
10
- class ModelBase < ::ActiveRecord::Base
11
- def self.deleted_column
12
- "deleted_at"
13
- end
10
+ if defined?(ActiveRecord) then
11
+ class ModelBase < ::ActiveRecord::Base
12
+ def self.deleted_column
13
+ "deleted_at"
14
+ end
14
15
 
15
- def self.status_column
16
- "status_id"
17
- end
16
+ def self.status_column
17
+ "status_id"
18
+ end
18
19
 
19
- def self.deleted_status_id
20
- 0
21
- end
20
+ def self.deleted_status_id
21
+ 0
22
+ end
22
23
 
23
- def self.[](what, only_id = false)
24
- self.__finalize(self.__safe_index_find(what), only_id)
25
- end
24
+ def self.[](what, only_id = false)
25
+ self.__finalize(self.__safe_index_find(what), only_id)
26
+ end
26
27
 
27
- def safe_id
28
- if self.id then self.id else 0 end
29
- end
28
+ def safe_id
29
+ if self.id then self.id else 0 end
30
+ end
30
31
 
31
- def editable?(user = nil)
32
- true
33
- end
32
+ def editable?(user = nil)
33
+ true
34
+ end
34
35
 
35
- def deletable?(user = nil)
36
- true
37
- end
36
+ def deletable?(user = nil)
37
+ true
38
+ end
38
39
 
39
- def delete(definitive = false)
40
- if !definitive then
41
- if self.deletable? then
42
- if self.has_attribute?(self.class.deleted_column) then
43
- self.update_attribute(self.class.deleted_column, DateTime.now)
44
- true
45
- elsif self.has_attribute?(self.class.status_column) then
46
- self.update_attribute(self.class.status_column, self.deleted_status)
47
- true
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
- super()
53
+ false
50
54
  end
51
55
  else
52
- false
56
+ super()
53
57
  end
54
- else
55
- super()
56
58
  end
57
- end
58
59
 
59
- def is?(other)
60
- other ? (self.id == self.class.__safe_index_find(other).id) : false
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
- def self.__finalize(record, only_id = false)
69
- if record then
70
- only_id ? record.id : record
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
- def self.__safe_index_find(what)
77
- record = nil
78
-
79
- begin
80
- record = self.__index_find(what)
81
- rescue ActiveRecord::RecordNotFound
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
- end
79
+
80
+ begin
81
+ record = self.__index_find(what)
82
+ rescue ActiveRecord::RecordNotFound
83
+ record = nil
84
+ end
84
85
 
85
- record
86
- end
86
+ record
87
+ end
88
+ end
89
+ else
90
+ class ModelBase
91
+ end
87
92
  end
88
93
  end
89
94
  end
@@ -10,7 +10,7 @@ module Cowtech
10
10
  MAJOR = 1
11
11
  MINOR = 9
12
12
  PATCH = 7
13
- BUILD = 5
13
+ BUILD = 6
14
14
 
15
15
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
16
16
  end
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.5
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-16 00:00:00.000000000Z
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: &70139848980280 !ruby/object:Gem::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: *70139848980280
24
+ version_requirements: *70126381000440
25
25
  description: A general purpose Rails utility plugin.
26
26
  email: shogun_panda@me.com
27
27
  executables: []