kuppayam 0.1.37 → 0.1.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/activatable.rb +49 -0
- data/lib/kuppayam/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0bf3c894f6c4d7a47ffb2a60759617501cd8b1ce51d0164d77b77ecf84f39309
|
4
|
+
data.tar.gz: b68c345ab22d3cc2cbb2528f52d7bd48843a6657aa580d2ba8a2781b42be5c0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e628d842c47e47bdf112f3d08cdd269cd8cbb2135c4e317b1f00b659b256c2f610e118a7234fbfe2edc3733d4353c64cced9e3a4374b6209f9890403f6bbd0da
|
7
|
+
data.tar.gz: d73ee303561b188adce4b1536f085e797302b03a58882030fc5ae320a10807445a7cc9aa8aae6b8513e55561323c07d8c88642a5d03f3d77df90b53a64261ae9
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Activatable
|
2
|
+
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
# Constants
|
6
|
+
ACTIVE = "active"
|
7
|
+
INACTIVE = "inactive"
|
8
|
+
REMOVED = "removed"
|
9
|
+
ARCHIVED = "archived"
|
10
|
+
|
11
|
+
STATUS = {"Active" => ACTIVE, "Inactive" => INACTIVE, "Archived" => ARCHIVED, "Removed" => REMOVED}
|
12
|
+
STATUS_REVERSE = {ACTIVE => "Active", INACTIVE => "Inactive", ARCHIVED => "Archived", REMOVED => "Removed"}
|
13
|
+
STATUS_UI_CLASS = {ACTIVE => "success", INACTIVE => "default", ARCHIVED => "default", REMOVED => "danger"}
|
14
|
+
STATUS_UI_ICON = {ACTIVE => "fa-check", INACTIVE => "fa-square-o", ARCHIVED => "fa-archive", REMOVED => "fa-remove"}
|
15
|
+
|
16
|
+
included do
|
17
|
+
|
18
|
+
validates :status, :presence=> true, :inclusion => {:in => STATUS_REVERSE.keys, :presence_of => :status, :message => "%{value} is not a valid status" }
|
19
|
+
|
20
|
+
state_machine :status, initial: INACTIVE do
|
21
|
+
event :publish do
|
22
|
+
transition [INACTIVE, ARCHIVED] => ACTIVE
|
23
|
+
end
|
24
|
+
event :unpublish do
|
25
|
+
transition [ACTIVE, REMOVED, ARCHIVED] => INACTIVE
|
26
|
+
end
|
27
|
+
event :remove do
|
28
|
+
transition [ACTIVE, INACTIVE, ARCHIVED] => REMOVED
|
29
|
+
end
|
30
|
+
event :archive do
|
31
|
+
transition [ACTIVE, INACTIVE, REMOVED] => ARCHIVED
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
scope :active, -> { where(status: ACTIVE) }
|
36
|
+
scope :inactive, -> { where(status: INACTIVE) }
|
37
|
+
scope :removed, -> { where(status: REMOVED) }
|
38
|
+
scope :archived, -> { where(status: ARCHIVED) }
|
39
|
+
|
40
|
+
scope :active_and_inactive, -> { where(status: [ACTIVE, INACTIVE]) }
|
41
|
+
|
42
|
+
scope :status, lambda { |status| where("LOWER(status)='#{status}'") }
|
43
|
+
end
|
44
|
+
|
45
|
+
def display_status
|
46
|
+
STATUS_REVERSE[self.status]
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/lib/kuppayam/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuppayam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -427,6 +427,7 @@ files:
|
|
427
427
|
- app/helpers/render_helper.rb
|
428
428
|
- app/helpers/resource_helper.rb
|
429
429
|
- app/helpers/resource_view_helper.rb
|
430
|
+
- app/models/concerns/activatable.rb
|
430
431
|
- app/models/concerns/approvable.rb
|
431
432
|
- app/models/concerns/featureable.rb
|
432
433
|
- app/models/concerns/publishable.rb
|