constantize 0.1.6 → 0.1.7
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 +7 -7
- data/lib/constantize/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -18,7 +18,7 @@ end
|
|
18
18
|
or
|
19
19
|
|
20
20
|
<pre>
|
21
|
-
|
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
|
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 |
|
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 |
|
116
|
+
| 1 | noaa |
|
117
117
|
| .. |
|
118
118
|
+----+---------+
|
119
119
|
|
120
120
|
then your model definition would look like:
|
121
121
|
|
122
|
-
class
|
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
|
131
|
+
class BuoyType < ActiveRecord::Base
|
132
132
|
constantize :name, :id
|
133
133
|
..
|
134
134
|
end
|
135
135
|
|
136
|
-
and your call to
|
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
|
data/lib/constantize/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
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-
|
17
|
+
date: 2010-11-15 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|