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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0d53aeb096234dd00bc3724f3010a4725f7042f4bd80c49d70d46afc5061b8f
4
- data.tar.gz: 36517488c881016e74bb3197d2783bbffe50d3ac639e6b8e5e2d69448cf0ca6e
3
+ metadata.gz: 0bf3c894f6c4d7a47ffb2a60759617501cd8b1ce51d0164d77b77ecf84f39309
4
+ data.tar.gz: b68c345ab22d3cc2cbb2528f52d7bd48843a6657aa580d2ba8a2781b42be5c0c
5
5
  SHA512:
6
- metadata.gz: 179cc93b5a8eb5501465a1b531f8993fc84f00e234943030d0c474d10bc94b405fd40535cddeeebb648134dbea10f25b1fdab30ac2ccc939f495a0d6be0d569d
7
- data.tar.gz: 3f551bfd959b18b5e3140fbb9b241be1f44582a52c051142111944fcde360cd7b95fdf213806814810f5109f41b5e06ab69f49ebcd936d74f8ad479679b49d69
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
@@ -1,3 +1,3 @@
1
1
  module Kuppayam
2
- VERSION = '0.1.37'
2
+ VERSION = '0.1.38'
3
3
  end
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.37
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-17 00:00:00.000000000 Z
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