enumbler 0.6.7 → 0.6.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +12 -0
- data/lib/enumbler.rb +2 -0
- data/lib/enumbler/core_ext/symbol/case_equality_operator.rb +22 -0
- data/lib/enumbler/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ddaace87d45b05778db532d5d0d4d4b28a475a02ec7079f1dff8820edc05d24
|
4
|
+
data.tar.gz: b24dd09f614e8e32bed14b17bd9a36a8db1907dd4cb6e7614f73897394de3ef6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98349a3658d0cef8674e4a63a577a4b9e71279a4051d292f9b817fd5d8e1a2c0c837fdbb3b3cc01cac6de6219558a567eaafc9b0567d35e09bfe7b5d1689ce2c
|
7
|
+
data.tar.gz: 2a52456e1524c22fd224e18421fea42bff5f45fd35f016dddce701df59c7ae5edb3738555faa26ce2fee4afaae7d94043997a6e25d15414cba5bd7872f97a237
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -129,6 +129,18 @@ class Feeling < ApplicationRecord
|
|
129
129
|
end
|
130
130
|
```
|
131
131
|
|
132
|
+
## Core ext
|
133
|
+
|
134
|
+
Adds case equality power to the `Symbol` class allowing you to use case methods directly against an enabled instance:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
case Color.black
|
138
|
+
when :black
|
139
|
+
'not surprised'
|
140
|
+
when :blue, :purple
|
141
|
+
'very surprised'
|
142
|
+
end
|
143
|
+
|
132
144
|
## Development
|
133
145
|
|
134
146
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/enumbler.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Use case equality operator with an enabled class.
|
4
|
+
#
|
5
|
+
# case House.black
|
6
|
+
# when :black
|
7
|
+
# 'this is true'
|
8
|
+
# when :blue, :purple
|
9
|
+
# 'this is not'
|
10
|
+
# end
|
11
|
+
class Symbol
|
12
|
+
def ===(other)
|
13
|
+
super ||
|
14
|
+
other.class.included_modules.include?(Enumbler::Enabler) &&
|
15
|
+
other.enumble.enum == self
|
16
|
+
|
17
|
+
# Calling #enumble on a new instance that has not been defined raises an
|
18
|
+
# error, so catching that edge case here
|
19
|
+
rescue Enumbler::Error
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
data/lib/enumbler/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumbler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damon Timm
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- enumbler.gemspec
|
158
158
|
- lib/enumbler.rb
|
159
159
|
- lib/enumbler/collection.rb
|
160
|
+
- lib/enumbler/core_ext/symbol/case_equality_operator.rb
|
160
161
|
- lib/enumbler/enabler.rb
|
161
162
|
- lib/enumbler/enumble.rb
|
162
163
|
- lib/enumbler/version.rb
|