constantize 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +7 -7
  2. data/lib/constantize/version.rb +1 -1
  3. metadata +3 -3
data/README.md CHANGED
@@ -18,7 +18,7 @@ end
18
18
  or
19
19
 
20
20
  <pre>
21
- User.create(:login => :foo, :user_status => UserStatus::ACTIVE)
21
+ Bouy.create(:name => :foo, :bouy_type => BuoyType::NOAA)
22
22
  </pre>
23
23
 
24
24
  but weren't sure the best / most efficient way to implement?
@@ -94,7 +94,7 @@ where :key is the name of the field that will be used to build the finder.
94
94
 
95
95
  E.g.,
96
96
 
97
- class AccountStatus < ActiveRecord::Base
97
+ class BuoyType < ActiveRecord::Base
98
98
  constantize :name
99
99
  ..
100
100
  end
@@ -104,7 +104,7 @@ this would assume that your account_statuses table looked something like:
104
104
  +----+---------+
105
105
  | id | name |
106
106
  +----+---------+
107
- | 1 | active |
107
+ | 1 | noaa |
108
108
  | .. |
109
109
  +----+---------+
110
110
 
@@ -113,13 +113,13 @@ if your table used a different field, say :title, rather than :name:
113
113
  +----+---------+
114
114
  | id | title |
115
115
  +----+---------+
116
- | 1 | active |
116
+ | 1 | noaa |
117
117
  | .. |
118
118
  +----+---------+
119
119
 
120
120
  then your model definition would look like:
121
121
 
122
- class AccountStatus < ActiveRecord::Base
122
+ class BuoyType < ActiveRecord::Base
123
123
  constantize :title
124
124
  ..
125
125
  end
@@ -128,12 +128,12 @@ Finally, if you wanted only the :id to be returned from the constant call (rathe
128
128
  the entire model) you could do:
129
129
 
130
130
 
131
- class AccountStatus < ActiveRecord::Base
131
+ class BuoyType < ActiveRecord::Base
132
132
  constantize :name, :id
133
133
  ..
134
134
  end
135
135
 
136
- and your call to AccountStatus::ACTIVE would return only the interger :id value (1 in this
136
+ and your call to BuoyType::NOAA would return only the interger :id value (1 in this
137
137
  case).
138
138
 
139
139
  ## Note on Patches/Pull Requests
@@ -1,3 +1,3 @@
1
1
  module Constantize
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 6
9
- version: 0.1.6
8
+ - 7
9
+ version: 0.1.7
10
10
  platform: ruby
11
11
  authors:
12
12
  - Adam Weller
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-07 01:00:00 -04:00
17
+ date: 2010-11-15 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency