has_enumeration 0.2.1 → 0.2.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.
Files changed (3) hide show
  1. data/Rakefile +5 -31
  2. data/VERSION +1 -1
  3. metadata +7 -33
data/Rakefile CHANGED
@@ -12,37 +12,11 @@ Extends ActiveRecord with the has_enumeration method allowing a symbolic
12
12
  enumeration to be stored in an ActiveRecord attribute. The enumeration is
13
13
  specified as a mapping between symbols and their underlying representation
14
14
  in the database. Predicates are provided for each symbol in the enumeration
15
- and the symbols may be used in finder methods. For example:
16
-
17
- class TrafficLight < ActiveRecord::Base
18
- # Implicit mapping when the attribute is a string storing the string
19
- # version of the symbol:
20
- has_enumeration :color, [:red, :yellow, :green]
21
-
22
- # Explicit mappings between symbols and underlying values are also
23
- # supported. E.g.:
24
- # has_enumeration :color, :red => 1, :yellow => 2, :green => 3
25
- end
26
-
27
- tl = TrafficLight.new
28
- tl.color = :red
29
- tl.color.value # ==> :red
30
- tl.color.red? # ==> true
31
- tl.color.yellow? # ==> false
32
-
33
- TrafficLight.all(:conditions => {:color => :red}) # ==> all red traffic lights
34
-
35
- When using ActiveRecord 3, the symbolic values can also be used when interacting
36
- with the underlying Arel attributes for a model:
37
-
38
- attr = TrafficLight.arel_table[:color]
39
- TrafficLight.where(attr.in([:yellow, :green])) # ==> yellow or green lights
40
-
41
- has_enumeration has been tested with:
42
-
43
- Rubies: Ruby 1.8.7, Ruby 1.9.2, and JRuby 1.5.1.
44
- ActiveRecord: 2.3.8 and 3.0.0.rc
45
- EOF
15
+ and the symbols may be used in finder methods. When using ActiveRecord 3,
16
+ the symbols may also be used when interacting with the underlying Arel attribute
17
+ for the enumeration. has_enumeration has been tested with Ruby 1.8.7,
18
+ Ruby 1.9.2, JRuby 1.5.1, ActiveRecord 2.3.8, and ActiveRecord 3.0.0.rc.
19
+ EOF
46
20
  gemspec.email = "greg@rujubu.com"
47
21
  gemspec.homepage = "http://github.com/gregspurrier/has_enumeration"
48
22
  gemspec.author = "Greg Spurrier"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_enumeration
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Greg Spurrier
@@ -24,36 +24,10 @@ description: |
24
24
  enumeration to be stored in an ActiveRecord attribute. The enumeration is
25
25
  specified as a mapping between symbols and their underlying representation
26
26
  in the database. Predicates are provided for each symbol in the enumeration
27
- and the symbols may be used in finder methods. For example:
28
-
29
- class TrafficLight < ActiveRecord::Base
30
- # Implicit mapping when the attribute is a string storing the string
31
- # version of the symbol:
32
- has_enumeration :color, [:red, :yellow, :green]
33
-
34
- # Explicit mappings between symbols and underlying values are also
35
- # supported. E.g.:
36
- # has_enumeration :color, :red => 1, :yellow => 2, :green => 3
37
- end
38
-
39
- tl = TrafficLight.new
40
- tl.color = :red
41
- tl.color.value # ==> :red
42
- tl.color.red? # ==> true
43
- tl.color.yellow? # ==> false
44
-
45
- TrafficLight.all(:conditions => {:color => :red}) # ==> all red traffic lights
46
-
47
- When using ActiveRecord 3, the symbolic values can also be used when interacting
48
- with the underlying Arel attributes for a model:
49
-
50
- attr = TrafficLight.arel_table[:color]
51
- TrafficLight.where(attr.in([:yellow, :green])) # ==> yellow or green lights
52
-
53
- has_enumeration has been tested with:
54
-
55
- Rubies: Ruby 1.8.7, Ruby 1.9.2, and JRuby 1.5.1.
56
- ActiveRecord: 2.3.8 and 3.0.0.rc
27
+ and the symbols may be used in finder methods. When using ActiveRecord 3,
28
+ the symbols may also be used when interacting with the underlying Arel attribute
29
+ for the enumeration. has_enumeration has been tested with Ruby 1.8.7,
30
+ Ruby 1.9.2, JRuby 1.5.1, ActiveRecord 2.3.8, and ActiveRecord 3.0.0.rc.
57
31
 
58
32
  email: greg@rujubu.com
59
33
  executables: []