ar-enums 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/ar-enums.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ar-enums}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Emmanuel Nicolau"]
12
- s.date = %q{2010-02-11}
12
+ s.date = %q{2010-04-15}
13
13
  s.description = %q{Provides a simple way for defining enumerations in ActiveRecord models}
14
14
  s.email = %q{emmanicolau@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
44
44
  s.homepage = %q{http://github.com/eeng/ar-enums}
45
45
  s.rdoc_options = ["--charset=UTF-8"]
46
46
  s.require_paths = ["lib"]
47
- s.rubygems_version = %q{1.3.5}
47
+ s.rubygems_version = %q{1.3.6}
48
48
  s.summary = %q{Enumerations for ActiveRecord models}
49
49
  s.test_files = [
50
50
  "spec/enum_definition_spec.rb",
@@ -23,7 +23,7 @@ module ActiveRecord
23
23
  end
24
24
 
25
25
  def define_enums_getter field, enums
26
- define_class_method(field.enums_getter) { enums }
26
+ meta_def(field.enums_getter) { enums }
27
27
  end
28
28
 
29
29
  def define_enum_getter_and_setter field, enums
@@ -12,11 +12,4 @@ class Object
12
12
  def class_def name, &blk
13
13
  class_eval { define_method name, &blk }
14
14
  end
15
-
16
- # Defines a class method
17
- def define_class_method name, &blk
18
- self.class.instance_eval do
19
- define_method name, &blk
20
- end
21
- end
22
15
  end
@@ -83,7 +83,18 @@ end
83
83
 
84
84
  describe "External enumerations" do
85
85
  before do
86
- define_model_class 'State', 'ActiveRecord::Enum' do
86
+ define_model_class 'CountryState', 'ActiveRecord::Enum' do
87
+ enumeration do
88
+ ca
89
+ tx
90
+ end
91
+ end
92
+
93
+ define_model_class 'Country' do
94
+ enum :state, :class_name => 'CountryState'
95
+ end
96
+
97
+ define_model_class 'TrafficLightState', 'ActiveRecord::Enum' do
87
98
  enumeration do
88
99
  green :rgb => 0x0F0
89
100
  red :rgb => 0xF00
@@ -91,7 +102,7 @@ describe "External enumerations" do
91
102
  end
92
103
 
93
104
  define_model_class 'TrafficLight' do
94
- enum :state
105
+ enum :state, :class_name => 'TrafficLightState'
95
106
  end
96
107
  end
97
108
 
@@ -101,20 +112,21 @@ describe "External enumerations" do
101
112
  end
102
113
 
103
114
  it "should be posible to access all enums from withing the owner" do
104
- TrafficLight.states.should equal(State.all)
115
+ TrafficLight.states.should equal(TrafficLightState.all)
116
+ Country.states.should equal(CountryState.all)
105
117
  end
106
118
 
107
119
  it "should accept :class_name options to override de class of the external enum" do
108
120
  define_model_class 'TrafficLight' do
109
- enum :state_on_weekdays, :class_name => 'State'
110
- enum :state_on_weekends, :class_name => 'State'
121
+ enum :state_on_weekdays, :class_name => 'TrafficLightState'
122
+ enum :state_on_weekends, :class_name => 'TrafficLightState'
111
123
  end
112
- TrafficLight.state_on_weekdays.should equal(State.all)
113
- TrafficLight.state_on_weekends.should equal(State.all)
124
+ TrafficLight.state_on_weekdays.should equal(TrafficLightState.all)
125
+ TrafficLight.state_on_weekends.should equal(TrafficLightState.all)
114
126
  end
115
127
 
116
128
  it "external enums should be instances of the subclass of Enum" do
117
- State.all.each { |s| s.should be_a(State) }
129
+ TrafficLightState.all.each { |s| s.should be_a(TrafficLightState) }
118
130
  end
119
131
 
120
132
  it "should be posible to define new methods in Enum subclass" do
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-enums
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 1
9
+ version: 0.3.1
5
10
  platform: ruby
6
11
  authors:
7
12
  - Emmanuel Nicolau
@@ -9,19 +14,23 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-11 00:00:00 -02:00
17
+ date: 2010-04-15 00:00:00 -03:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: rspec
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 1
29
+ - 2
30
+ - 9
23
31
  version: 1.2.9
24
- version:
32
+ type: :development
33
+ version_requirements: *id001
25
34
  description: Provides a simple way for defining enumerations in ActiveRecord models
26
35
  email: emmanicolau@gmail.com
27
36
  executables: []
@@ -68,18 +77,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
77
  requirements:
69
78
  - - ">="
70
79
  - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
71
82
  version: "0"
72
- version:
73
83
  required_rubygems_version: !ruby/object:Gem::Requirement
74
84
  requirements:
75
85
  - - ">="
76
86
  - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
77
89
  version: "0"
78
- version:
79
90
  requirements: []
80
91
 
81
92
  rubyforge_project:
82
- rubygems_version: 1.3.5
93
+ rubygems_version: 1.3.6
83
94
  signing_key:
84
95
  specification_version: 3
85
96
  summary: Enumerations for ActiveRecord models