enumerate_it 0.7.6 → 0.7.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/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +4 -4
- data/lib/enumerate_it.rb +1 -1
- data/lib/version.rb +1 -1
- data/spec/enumerate_it_spec.rb +22 -0
- metadata +2 -2
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -137,11 +137,11 @@ This will create:
|
|
137
137
|
|
138
138
|
* If you pass the :create_scopes option as 'true', it will create a scope method for each enumeration option (this option defaults to false):
|
139
139
|
|
140
|
-
|
141
|
-
|
142
|
-
|
140
|
+
class Person < ActiveRecord::Base
|
141
|
+
has_enumeration_for :relationship_status, :with => RelationshipStatus, :create_scopes => true
|
142
|
+
end
|
143
143
|
|
144
|
-
|
144
|
+
Person.married.to_sql # => SELECT "people".* FROM "people" WHERE "people"."relationship_status" = 1
|
145
145
|
|
146
146
|
NOTE: The :create_scopes option can only be used for Rails.version >= 3.0.0.
|
147
147
|
|
data/lib/enumerate_it.rb
CHANGED
data/lib/version.rb
CHANGED
data/spec/enumerate_it_spec.rb
CHANGED
@@ -26,6 +26,15 @@ class TestEnumerationWithExtendedBehaviour < EnumerateIt::Base
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
class Foobar < EnumerateIt::Base
|
30
|
+
associate_values(
|
31
|
+
:bar => 'foo'
|
32
|
+
)
|
33
|
+
end
|
34
|
+
class BaseClass
|
35
|
+
include EnumerateIt
|
36
|
+
has_enumeration_for :foobar, :with => TestEnumeration
|
37
|
+
end
|
29
38
|
describe EnumerateIt do
|
30
39
|
before :each do
|
31
40
|
class TestClass
|
@@ -57,6 +66,19 @@ describe EnumerateIt do
|
|
57
66
|
it "stores the enumeration class in a class-level hash" do
|
58
67
|
TestClass.enumerations[:foobar].should == TestEnumeration
|
59
68
|
end
|
69
|
+
context 'declaring a simple enum on an inherited class' do
|
70
|
+
before do
|
71
|
+
class SomeClass < BaseClass
|
72
|
+
has_enumeration_for :foobar
|
73
|
+
end
|
74
|
+
@target = SomeClass.new
|
75
|
+
end
|
76
|
+
it 'should have use the corret class' do
|
77
|
+
@base = BaseClass.new
|
78
|
+
@base.class.enumerations[:foobar].should == TestEnumeration
|
79
|
+
@target.class.enumerations[:foobar].should == Foobar
|
80
|
+
end
|
81
|
+
end
|
60
82
|
|
61
83
|
context "passing the value of each option without the human string (just the value, without an array)" do
|
62
84
|
before :each do
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: enumerate_it
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.7.
|
5
|
+
version: 0.7.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "C\xC3\xA1ssio Marques"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-29 00:00:00 -03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|