str_enum 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50458b9b15471d5a6656996aafd655245fba64fd
4
- data.tar.gz: f04c3fa378db71e53714cd844fe99c776e0ca42f
3
+ metadata.gz: f1af2d9185c46190d199572f4ead3c7be624044b
4
+ data.tar.gz: 2239d75b7693917cd5e7843ea5d168ee418b93e2
5
5
  SHA512:
6
- metadata.gz: f3eb2d10031cdf8a0b7967b02d2cf4624f0893480b05e8dbec893d1cc00e693a3c1acca73f4fc8fe361f4f4830f98e492f03eaf711bef7d29dfcadb67eae2414
7
- data.tar.gz: 62c5e91bc1417967d641aec5865ce2120ad8b2fe01d2b09389bf205cc0778dc84b2a8401e386572f020e6aef9c4f5e5c7d1cc41083a9dcc5c12c2042bed8a46b
6
+ metadata.gz: b9f5c6b3737eb8d34180c35b81806e341dc8f2cce0a0d8d2c5e67b334b46fa54b755f502a14138ea4f8a4db5b842c42ff1eaedfbc4deaa529e22fad83d82356f
7
+ data.tar.gz: 32c14db6244b386b217fcc16444986ebcf3ab5ed0f0837a406d2c17ded2f299fcda23e2e881ec93e3540de05263c4d0aede531206a44d2e7a4249519cbba80d5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.2
2
+
3
+ - Added method to list values
4
+
1
5
  ## 0.1.1
2
6
 
3
7
  - Added `prefix` option
data/README.md CHANGED
@@ -16,7 +16,13 @@ Add this line to your application’s Gemfile:
16
16
  gem 'str_enum'
17
17
  ```
18
18
 
19
- In your models, use:
19
+ Add a string column to your model.
20
+
21
+ ```ruby
22
+ add_column :users, :status, :string
23
+ ```
24
+
25
+ And use:
20
26
 
21
27
  ```ruby
22
28
  class User < ActiveRecord::Base
@@ -47,6 +53,12 @@ user.active?
47
53
  user.archived?
48
54
  ```
49
55
 
56
+ #### Forms
57
+
58
+ ```erb
59
+ <%= f.select :status, User.statuses.map { |s| [s.titleize, s] } %>
60
+ ```
61
+
50
62
  ## Options
51
63
 
52
64
  Choose which features you want with:
@@ -57,7 +69,7 @@ class User < ActiveRecord::Base
57
69
  end
58
70
  ```
59
71
 
60
- Prevent name collisions with the `prefix` option.
72
+ Prevent method name collisions with the `prefix` option.
61
73
 
62
74
  ```ruby
63
75
  class User < ActiveRecord::Base
@@ -1,3 +1,3 @@
1
1
  module StrEnum
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/str_enum.rb CHANGED
@@ -18,6 +18,9 @@ module StrEnum
18
18
  after_initialize do
19
19
  send("#{column}=", values.first) unless send(column)
20
20
  end
21
+ define_singleton_method column.to_s.pluralize do
22
+ values
23
+ end
21
24
  end
22
25
  end
23
26
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: str_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane