enum_simulator 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/Rakefile +3 -3
- data/enum_simulator.gemspec +4 -4
- data/lib/enum_simulator.rb +1 -1
- data/spec/enum_simulator_spec.rb +4 -0
- data/spec/resources/schema +5 -0
- metadata +4 -3
data/README.rdoc
CHANGED
@@ -44,6 +44,6 @@ And then in a view you can do something like this:
|
|
44
44
|
|
45
45
|
You could also have used the PickupTruck::TRUCK_TYPES constant in this example, but the enumerated_attributes hash is a handy way to access whatever values were passed into the enum definition, especially if you haven't put them in a constant somewhere.
|
46
46
|
|
47
|
-
enum_simulator will handle validation of inclusion and conversion of the attribute values from symbols to strings and back internally. Honestly, that's really all it does - it's just such a common pattern that I figured we might as well have a more succinct way of using it. It will infer whether or not to allow assignment of nil to your attribute from the column definition. If your column allows null, then
|
47
|
+
enum_simulator will handle validation of inclusion and conversion of the attribute values from symbols to strings and back internally. Honestly, that's really all it does - it's just such a common pattern that I figured we might as well have a more succinct way of using it. It will infer whether or not to allow assignment of nil to your attribute from the column definition. If your column allows null, then the enumerated_attributes hash for that column will also include nil. This means you do not need an :include_blank in any form tags related to the attribute in question.
|
48
48
|
|
49
49
|
Copyright (c) 2012 Centresource, released under the MIT license
|
data/Rakefile
CHANGED
@@ -23,11 +23,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
23
23
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
24
24
|
end
|
25
25
|
|
26
|
-
Echoe.new('enum_simulator', '1.1.
|
26
|
+
Echoe.new('enum_simulator', '1.1.1') do |p|
|
27
27
|
p.description = 'A simple plugin for abstracting out standard ActiveRecord enumerated attributes.'
|
28
28
|
p.url = 'https://github.com/centresource/enum_simulator.git'
|
29
|
-
p.author = ['Jeremy Holland', 'Brandon Valentine']
|
30
|
-
p.email = ['jeremy@jeremypholland.com', 'brandon@brandonvalentine.com']
|
29
|
+
p.author = ['Jeremy Holland', 'Brandon Valentine', 'Steven Warren']
|
30
|
+
p.email = ['jeremy@jeremypholland.com', 'brandon@brandonvalentine.com', 'swarren@centresource.com']
|
31
31
|
p.ignore_pattern = ["tmp/*", "script/*"]
|
32
32
|
p.development_dependencies = []
|
33
33
|
end
|
data/enum_simulator.gemspec
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "enum_simulator"
|
5
|
-
s.version = "1.1.
|
5
|
+
s.version = "1.1.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Jeremy Holland, Brandon Valentine"]
|
9
|
-
s.date = "2012-
|
8
|
+
s.authors = ["Jeremy Holland, Brandon Valentine, Steven Warren"]
|
9
|
+
s.date = "2012-11-07"
|
10
10
|
s.description = "A simple plugin for abstracting out standard ActiveRecord enumerated attributes."
|
11
|
-
s.email = ["jeremy@jeremypholland.com", "brandon@brandonvalentine.com"]
|
11
|
+
s.email = ["jeremy@jeremypholland.com", "brandon@brandonvalentine.com", "swarren@centresource.com"]
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "lib/enum_simulator.rb"]
|
13
13
|
s.files = ["Gemfile", "MIT-LICENSE", "README.rdoc", "Rakefile", "enum_simulator.gemspec", "init.rb", "install.rb", "lib/enum_simulator.rb", "spec/enum_simulator_spec.rb", "spec/resources/schema", "spec/spec_helper.rb", "spec/support/models/other_thingies.rb", "spec/support/models/thingy.rb", "uninstall.rb", "Manifest"]
|
14
14
|
s.homepage = "https://github.com/centresource/enum_simulator.git"
|
data/lib/enum_simulator.rb
CHANGED
data/spec/enum_simulator_spec.rb
CHANGED
@@ -74,6 +74,10 @@ describe EnumSimulator do
|
|
74
74
|
Thingy.enumerated_attributes[:smell].should include(nil)
|
75
75
|
end
|
76
76
|
|
77
|
+
it "should not include multiple nils if a constant is used in mulitple validations" do
|
78
|
+
Foo::CONSTANT.select { |n| n == nil }.count.should == 1
|
79
|
+
end
|
80
|
+
|
77
81
|
describe "when an array is passed to enum" do
|
78
82
|
it "should be an array of all possible enumerable values for the key in question" do
|
79
83
|
Thingy.enumerated_attributes[:flavor].should be_a(Array)
|
data/spec/resources/schema
CHANGED
metadata
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enum_simulator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Jeremy Holland, Brandon Valentine
|
8
|
+
- Jeremy Holland, Brandon Valentine, Steven Warren
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A simple plugin for abstracting out standard ActiveRecord enumerated
|
15
15
|
attributes.
|
16
16
|
email:
|
17
17
|
- jeremy@jeremypholland.com
|
18
18
|
- brandon@brandonvalentine.com
|
19
|
+
- swarren@centresource.com
|
19
20
|
executables: []
|
20
21
|
extensions: []
|
21
22
|
extra_rdoc_files:
|