enum_simulator 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -2,13 +2,13 @@ Gemfile
2
2
  MIT-LICENSE
3
3
  README.rdoc
4
4
  Rakefile
5
- enum_simulator.gemspec
6
5
  init.rb
7
6
  install.rb
8
7
  lib/enum_simulator.rb
9
8
  spec/enum_simulator_spec.rb
10
9
  spec/resources/schema
11
10
  spec/spec_helper.rb
11
+ spec/support/models/Foo.rb
12
12
  spec/support/models/other_thingies.rb
13
13
  spec/support/models/thingy.rb
14
14
  uninstall.rb
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ 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.1') do |p|
26
+ Echoe.new('enum_simulator', '1.1.2') 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
29
  p.author = ['Jeremy Holland', 'Brandon Valentine', 'Steven Warren']
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "enum_simulator"
5
- s.version = "1.1.1"
5
+ s.version = "1.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeremy Holland, Brandon Valentine, Steven Warren"]
9
- s.date = "2012-11-07"
9
+ s.date = "2012-12-21"
10
10
  s.description = "A simple plugin for abstracting out standard ActiveRecord enumerated attributes."
11
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
- 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"]
13
+ s.files = ["Gemfile", "MIT-LICENSE", "README.rdoc", "Rakefile", "init.rb", "install.rb", "lib/enum_simulator.rb", "spec/enum_simulator_spec.rb", "spec/resources/schema", "spec/spec_helper.rb", "spec/support/models/Foo.rb", "spec/support/models/other_thingies.rb", "spec/support/models/thingy.rb", "uninstall.rb", "Manifest", "enum_simulator.gemspec"]
14
14
  s.homepage = "https://github.com/centresource/enum_simulator.git"
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Enum_simulator", "--main", "README.rdoc"]
16
16
  s.require_paths = ["lib"]
@@ -6,16 +6,17 @@ module EnumSimulator
6
6
 
7
7
  module ClassMethods
8
8
  def enum(attr, values)
9
+ val_dupe = values.dup
9
10
  if self.columns_hash[attr.to_s].respond_to? :null and self.columns_hash[attr.to_s].null
10
- if values.is_a? Hash
11
- values[nil] = ""
11
+ if val_dupe.is_a? Hash
12
+ val_dupe[nil] = ""
12
13
  else
13
- values << nil unless values.include? nil
14
+ val_dupe << nil
14
15
  end
15
16
  end
16
- valid = values.is_a?(Hash) ? values.keys : values
17
+ valid = val_dupe.is_a?(Hash) ? val_dupe.keys : val_dupe
17
18
  @enumerated_attributes ||= {}
18
- @enumerated_attributes[attr] = values
19
+ @enumerated_attributes[attr] = val_dupe
19
20
  validates_inclusion_of attr, :in => valid
20
21
 
21
22
  class_eval <<RUBY
@@ -74,8 +74,8 @@ 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
77
+ it "should not affect the original values of a constant passed in to the enum_simulator" do
78
+ Foo::CONSTANT.include?(nil).should be_false
79
79
  end
80
80
 
81
81
  describe "when an array is passed to enum" do
@@ -0,0 +1,5 @@
1
+ class Foo < ActiveRecord::Base
2
+ CONSTANT = [:one, :two, :three]
3
+ enum :first_enum, CONSTANT
4
+ enum :second_enum, CONSTANT
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enum_simulator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-07 00:00:00.000000000 Z
12
+ date: 2012-12-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A simple plugin for abstracting out standard ActiveRecord enumerated
15
15
  attributes.
@@ -27,17 +27,18 @@ files:
27
27
  - MIT-LICENSE
28
28
  - README.rdoc
29
29
  - Rakefile
30
- - enum_simulator.gemspec
31
30
  - init.rb
32
31
  - install.rb
33
32
  - lib/enum_simulator.rb
34
33
  - spec/enum_simulator_spec.rb
35
34
  - spec/resources/schema
36
35
  - spec/spec_helper.rb
36
+ - spec/support/models/Foo.rb
37
37
  - spec/support/models/other_thingies.rb
38
38
  - spec/support/models/thingy.rb
39
39
  - uninstall.rb
40
40
  - Manifest
41
+ - enum_simulator.gemspec
41
42
  homepage: https://github.com/centresource/enum_simulator.git
42
43
  licenses: []
43
44
  post_install_message: