yinum 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yinum (1.0.0)
4
+ yinum (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -19,7 +19,6 @@ module Enum::Helpers::EnumColumn
19
19
  # generating scopes and questioning methods
20
20
  e.by_name.each do |n, ev|
21
21
  scope n, where(attr => ev)
22
- define_method("#{n}?") { self[attr] == ev }
23
22
  end
24
23
  end
25
24
 
data/lib/enum.rb CHANGED
@@ -28,7 +28,10 @@ class Enum
28
28
  @by_name.each_value(&block)
29
29
  end
30
30
 
31
- def [](name_or_value)
31
+ def [](*name_or_values)
32
+ return name_or_values.map { |name_or_value| self[name_or_value] } if name_or_values.length > 1
33
+
34
+ name_or_value = name_or_values.first
32
35
  ev = @by_name[name_or_value] || @by_value[name_or_value]
33
36
  raise "#{inspect} does not know #{name_or_value.inspect}" if ev.nil?
34
37
  ev
@@ -1,6 +1,15 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Enum do
4
+ context "accessors" do
5
+ before { @enum = Enum.new(:MY_COLORS, :red => 1, :blue => 2) }
6
+
7
+ specify { @enum.red.should == 1 }
8
+ specify { @enum[:red].should == 1 }
9
+ specify { expect { @enum[:black] }.to raise_error(StandardError) }
10
+ specify { @enum[:red, :blue].should == [1, 2] }
11
+ end # context "accessors
12
+
4
13
  context "keys on left and right" do
5
14
  before { @enum = Enum.new(:MY_COLORS, :red => 1, 2 => :blue) }
6
15
  subject { @enum }
data/yinum.gemspec CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "yinum"
6
- s.version = "1.1.0"
6
+ s.version = "1.2.0"
7
7
  s.authors = ["Oded Niv"]
8
8
  s.email = ["oded.niv@gmail.com"]
9
9
  s.homepage = "https://github.com/toplex/enum"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yinum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
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: 2013-03-06 00:00:00.000000000 Z
12
+ date: 2013-03-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Yummy implementation of enum that gives integer values with a special
15
15
  wrapping.