platanus 0.0.5 → 0.0.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.
- data/lib/platanus/activable.rb +10 -7
- data/lib/platanus/version.rb +1 -1
- metadata +1 -1
data/lib/platanus/activable.rb
CHANGED
@@ -10,7 +10,6 @@ module Platanus
|
|
10
10
|
# This module also defines a +remove+ callback.
|
11
11
|
#
|
12
12
|
module Activable
|
13
|
-
|
14
13
|
def self.included(base)
|
15
14
|
base.define_callbacks :remove
|
16
15
|
base.attr_protected :removed_at
|
@@ -36,12 +35,6 @@ module Platanus
|
|
36
35
|
def after_remove(_callback)
|
37
36
|
self.set_callback :remove, :after, _callback
|
38
37
|
end
|
39
|
-
|
40
|
-
## Disables default scopes and creates an additional 'active' scope
|
41
|
-
def explicit_scopes(_active_scope_name='active')
|
42
|
-
self.send(:default_scope, nil)
|
43
|
-
self.send(:scope, _active_scope_name, self.where(:removed_at => nil))
|
44
|
-
end
|
45
38
|
end
|
46
39
|
|
47
40
|
# Returns true if object hasnt been removed.
|
@@ -68,6 +61,16 @@ module Platanus
|
|
68
61
|
end
|
69
62
|
end
|
70
63
|
end
|
64
|
+
|
65
|
+
## Same as Activable but defines an 'alive' scope and no default scope.
|
66
|
+
module ActivableExplicit
|
67
|
+
def self.included(base)
|
68
|
+
base.define_callbacks :remove
|
69
|
+
base.attr_protected :removed_at
|
70
|
+
base.send(:scope, 'alive', base.where(:removed_at => nil))
|
71
|
+
base.extend ActivableClassMethods
|
72
|
+
end
|
73
|
+
end
|
71
74
|
end
|
72
75
|
|
73
76
|
|
data/lib/platanus/version.rb
CHANGED