status-manager 0.1.1 → 0.1.2
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/README.md +35 -1
- data/lib/status-manager/version.rb +1 -1
- data/status-manager-0.1.1.gem +0 -0
- data/status-manager.gemspec +1 -1
- data/status_manager_test.sqlite3 +0 -0
- data/test/status-manager_test.rb +1 -0
- metadata +3 -1
data/README.md
CHANGED
@@ -1,4 +1,38 @@
|
|
1
1
|
status-manager
|
2
2
|
==============
|
3
3
|
|
4
|
-
|
4
|
+
## Description
|
5
|
+
Simple ActiveRecord Model Status Manager
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
### Rails 3.x
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'status-manager'
|
13
|
+
```
|
14
|
+
|
15
|
+
### Example
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
class Product < ActiveRecord::Base
|
19
|
+
attr_accessible :title, :status
|
20
|
+
|
21
|
+
# acts_as_status :status_attribute in model, {:status_value => 'status_value that is saved in database'}
|
22
|
+
acts_as_status :status, :onsale => 'onsale', :reject => 'reject', :pending => 'pending', :soldout => 'soldout'
|
23
|
+
status_group :close, [:reject, :pending]
|
24
|
+
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# select
|
30
|
+
@onsale_products = Product.status_onsale
|
31
|
+
@closed_products = Product.status_close
|
32
|
+
|
33
|
+
assert @onsale_products.first.status_onsale?
|
34
|
+
assert @closed_products.first.status_close?
|
35
|
+
|
36
|
+
# update
|
37
|
+
@closed_products.first.status_to(:onsale) ## => update just attribute value
|
38
|
+
@closed_products.first.update_status_onsale ## => update with database
|
Binary file
|
data/status-manager.gemspec
CHANGED
data/status_manager_test.sqlite3
CHANGED
Binary file
|
data/test/status-manager_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: status-manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -25,6 +25,8 @@ files:
|
|
25
25
|
bGliL3N0YXR1cy1tYW5hZ2VyLnJi
|
26
26
|
- !binary |-
|
27
27
|
bGliL3N0YXR1cy1tYW5hZ2VyL3ZlcnNpb24ucmI=
|
28
|
+
- !binary |-
|
29
|
+
c3RhdHVzLW1hbmFnZXItMC4xLjEuZ2Vt
|
28
30
|
- !binary |-
|
29
31
|
c3RhdHVzLW1hbmFnZXIuZ2Vtc3BlYw==
|
30
32
|
- !binary |-
|