enumbler 0.6.7 → 0.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b325cf47a0a64b573f1347bffbbea7338cc57b7422dfdf3f0da39d412274d8cb
4
- data.tar.gz: 10affa6956ef071ec34ad4195379d632b86945745e8d0eb7718fc8735427fe9e
3
+ metadata.gz: 4ddaace87d45b05778db532d5d0d4d4b28a475a02ec7079f1dff8820edc05d24
4
+ data.tar.gz: b24dd09f614e8e32bed14b17bd9a36a8db1907dd4cb6e7614f73897394de3ef6
5
5
  SHA512:
6
- metadata.gz: a38a602c49f7a0bf3f69781b4a54d555bc92a23bd61788a27bbf858d75aa554599638a77af3afd8d2088b8e94fcc69768c63d3e2268b7ea0384fc4f74a955dfa
7
- data.tar.gz: 98fae8e4a32aa7207f55fe07128ca7e4730c50701cfac378756ff32c27e8b745ab471afb88401cf8096e75b42deffe7ec031d9d9e1d3d0ba97bdddc37774058c
6
+ metadata.gz: 98349a3658d0cef8674e4a63a577a4b9e71279a4051d292f9b817fd5d8e1a2c0c837fdbb3b3cc01cac6de6219558a567eaafc9b0567d35e09bfe7b5d1689ce2c
7
+ data.tar.gz: 2a52456e1524c22fd224e18421fea42bff5f45fd35f016dddce701df59c7ae5edb3738555faa26ce2fee4afaae7d94043997a6e25d15414cba5bd7872f97a237
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumbler (0.6.7)
4
+ enumbler (0.6.8)
5
5
  activerecord (>= 5.2.3, < 6.1)
6
6
  activesupport (>= 5.2.3, < 6.1)
7
7
 
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.
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'enumbler/core_ext/symbol/case_equality_operator'
4
+
3
5
  require 'enumbler/collection'
4
6
  require 'enumbler/enumble'
5
7
  require 'enumbler/enabler'
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Enumbler
4
- VERSION = '0.6.7'
4
+ VERSION = '0.6.8'
5
5
  end
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.7
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-08-05 00:00:00.000000000 Z
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