concerned_states 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -0
- data/concerned_states.gemspec +1 -2
- data/lib/concerned_states/stateable.rb +99 -0
- metadata +5 -4
- data/lib/concerned_states/version.rb +0 -3
data/README.rdoc
ADDED
data/concerned_states.gemspec
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "concerned_states/version"
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = "concerned_states"
|
7
|
-
s.version =
|
6
|
+
s.version = "0.1.0"
|
8
7
|
s.authors = ["Richard Hart"]
|
9
8
|
s.email = ["richard@ur-ban.com"]
|
10
9
|
s.homepage = ""
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module ConcernedStates
|
2
|
+
module Stateable
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
PASSIVE = "passive"
|
7
|
+
PENDING = "pending"
|
8
|
+
DECLINED = "declined"
|
9
|
+
APPROVED = "approved"
|
10
|
+
ACTIVE = "active"
|
11
|
+
FLAGGED = "flagged"
|
12
|
+
SUSPENDED = "suspended"
|
13
|
+
DELETED = "deleted"
|
14
|
+
STARTED = "started"
|
15
|
+
PAUSED = "paused"
|
16
|
+
CANCELLED = "cancelled"
|
17
|
+
COMPLETED = "completed"
|
18
|
+
ERRORED = "errored"
|
19
|
+
|
20
|
+
scope :passive,
|
21
|
+
where(:state => PASSIVE)
|
22
|
+
|
23
|
+
scope :pending,
|
24
|
+
where(:state => PENDING)
|
25
|
+
|
26
|
+
scope :declined,
|
27
|
+
where(:state => DECLINED)
|
28
|
+
|
29
|
+
scope :approved,
|
30
|
+
where(:state => APPROVED)
|
31
|
+
|
32
|
+
scope :active,
|
33
|
+
where(:state => ACTIVE)
|
34
|
+
|
35
|
+
scope :deleted,
|
36
|
+
where(:state => DELETED)
|
37
|
+
|
38
|
+
scope :completed,
|
39
|
+
where(:state => COMPLETED)
|
40
|
+
end
|
41
|
+
|
42
|
+
def passivate; self.state = PASSIVE; end
|
43
|
+
def passivate!; update_attribute(:state, PASSIVE); end
|
44
|
+
def passive?; self.state == PASSIVE; end
|
45
|
+
|
46
|
+
def pendinate; self.state = PENDING; end
|
47
|
+
def pendinate!; update_attribute(:state, PENDING); end
|
48
|
+
def pending?; self.state == PENDING; end
|
49
|
+
|
50
|
+
def decline; self.state = DECLINED; end
|
51
|
+
def decline!; update_attribute(:state, DECLINED); end
|
52
|
+
def declined?; self.state == DECLINED; end
|
53
|
+
|
54
|
+
def approve; self.state = APPROVED; end
|
55
|
+
def approve!; update_attribute(:state, APPROVE); end
|
56
|
+
def approved?; self.state == APPROVED; end
|
57
|
+
|
58
|
+
def activate; self.state = ACTIVE; end
|
59
|
+
def activate!; update_attribute(:state, ACTIVE); end
|
60
|
+
def active?; self.state == ACTIVE; end
|
61
|
+
|
62
|
+
def flag; self.state = FLAGGED; end
|
63
|
+
def flag!; update_attribute(:state, FLAGGED); end
|
64
|
+
def flagged?; self.state == FLAGGED; end
|
65
|
+
|
66
|
+
def suspend; self.state = SUSPENDED; end
|
67
|
+
def suspend!; update_attribute(:state, SUSPENDED); end
|
68
|
+
def suspended?; self.state == SUSPENDED; end
|
69
|
+
|
70
|
+
def delete; self.state = DELETED; end
|
71
|
+
def delete!; update_attribute(:state, DELETED); end
|
72
|
+
def deleted?; self.state == DELETED; end
|
73
|
+
|
74
|
+
def cancel; self.state = CANCELLED; end
|
75
|
+
def cancel!; update_attribute(:state, CANCELLED); end
|
76
|
+
def cancelled?; self.state == CANCELLED; end
|
77
|
+
|
78
|
+
def start; self.state = STARTED; end
|
79
|
+
def start!; update_attribute(:state, STARTED); end
|
80
|
+
def started?; self.state == STARTED; end
|
81
|
+
|
82
|
+
def pause; self.state = PAUSED; end
|
83
|
+
def pause!; update_attribute(:state, PAUSE); end
|
84
|
+
def paused?; self.state == PAUSED; end
|
85
|
+
|
86
|
+
def cancel; self.state = CANCELLED; end
|
87
|
+
def cancel!; update_attribute(:state, CANCELLED); end
|
88
|
+
def canceled?; self.state == CANCELLED; end
|
89
|
+
|
90
|
+
def complete; self.state = COMPLETED; end
|
91
|
+
def complete!; update_attribute(:state, COMPLETED); end
|
92
|
+
def completed?; self.state == COMPLETED; end
|
93
|
+
|
94
|
+
def error; self.state = ERRORED; end
|
95
|
+
def error!; update_attribute(:state, ERRORED); end
|
96
|
+
def errored?; self.state == ERRORED; end
|
97
|
+
|
98
|
+
end
|
99
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concerned_states
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Richard Hart
|
@@ -31,10 +31,11 @@ extra_rdoc_files: []
|
|
31
31
|
files:
|
32
32
|
- .gitignore
|
33
33
|
- Gemfile
|
34
|
+
- README.rdoc
|
34
35
|
- Rakefile
|
35
36
|
- concerned_states.gemspec
|
36
37
|
- lib/concerned_states.rb
|
37
|
-
- lib/concerned_states/
|
38
|
+
- lib/concerned_states/stateable.rb
|
38
39
|
has_rdoc: true
|
39
40
|
homepage: ""
|
40
41
|
licenses: []
|