cats_core 1.2.11 → 1.2.12

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: d9f57a513afb90596f709408275f30e41f9b4e4b45fe5807db6c3ef743e11b72
4
- data.tar.gz: ecbdbe4277fa2d4fff4558a3936aa7cc6668a0bc62d1660ba86b6c90cfa44801
3
+ metadata.gz: c6d9c981d6dfe00647462832e97d47af7fc677b5e092a5f675366ae1e49ac8dc
4
+ data.tar.gz: b24adf0ed11330190cfd57050c94ead1f871e183339351d2caebcc2b09597536
5
5
  SHA512:
6
- metadata.gz: 568910a95c3524abeb0b0aa227d1bb8fb505e1474610c22ce23588572550fe978c099f5c1ec78c43895db16bb97653660580a9c516a7d53babda91445eaf5847
7
- data.tar.gz: 0257f48eef8cce083a1b1783d4a744ded17c39feac5c016950a4b4509b145a139eaeb4632e7f5c3b33f8a95ea6e811e061941e6051c2b2ede174c9087bc0ee09
6
+ metadata.gz: 56857803a15398dadccd2396e3a2d1b4124b392258ecc180f678d70ddca5a3dafa7b222774b34a9b2d93e8d23aa928622de3d78772017020c7c67f7996ede95c
7
+ data.tar.gz: f7b0c9cdbacfec2c9836a80560b2c93a69281e4be503e850ee433ca64917d1703c4bf83d2d59c668495f93fa4371350e9573569ce87ea5207b45a54a18d8b8ac
@@ -3,7 +3,9 @@ module Cats
3
3
  class TransportRequest < ApplicationRecord
4
4
  DRAFT = 'Draft'.freeze
5
5
  APPROVED = 'Approved'.freeze
6
- STATUSES = [DRAFT, APPROVED].freeze
6
+ OPEN = 'Open'.freeze
7
+ CLOSED = 'Closed'.freeze
8
+ STATUSES = [DRAFT, APPROVED, OPEN, CLOSED].freeze
7
9
 
8
10
  belongs_to :requested_by, class_name: 'Cats::Core::User'
9
11
  belongs_to :approved_by, class_name: 'Cats::Core::User', optional: true
@@ -15,6 +17,28 @@ module Cats
15
17
 
16
18
  delegate(:full_name, to: :requested_by, prefix: true, allow_nil: true)
17
19
  delegate(:full_name, to: :approved_by, prefix: true, allow_nil: true)
20
+
21
+ def approve(approver)
22
+ raise(StandardError, 'Request is not open for approval.') unless status == DRAFT
23
+
24
+ self.approved_by = approver
25
+ self.status = APPROVED
26
+ save!
27
+ end
28
+
29
+ def open
30
+ raise(StandardError, 'Request is not approved for opening.') unless status == APPROVED
31
+
32
+ self.status = OPEN
33
+ save!
34
+ end
35
+
36
+ def close
37
+ raise(StandardError, 'Request is not open.') unless status == OPEN
38
+
39
+ self.status = CLOSED
40
+ save!
41
+ end
18
42
  end
19
43
  end
20
44
  end
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.2.11'.freeze
3
+ VERSION = '1.2.12'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.11
4
+ version: 1.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.