safe-hash-enum 0.4.4 → 0.4.5

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: 12b4195219a8cbc129dbe7355fceb9492ff234b71f762a3a79ad714ef1fb828d
4
- data.tar.gz: 8fdbbfd2d882048ba6e79eec9ec7c44116019bd4da96bc68ae3f5e054b34bece
3
+ metadata.gz: f3d0a446cc2c0ed1557281434982bb76b03705b164e37d36192579c77ad0ebfa
4
+ data.tar.gz: d2244782d1f0d6a5a572758e378acd2647a736f4744262f00fe5e07206ff24c8
5
5
  SHA512:
6
- metadata.gz: a85934bace64fd4ac0c86bad414ef5cc44914dcc5322e30444cdc1f845311c626ed61109f43efe81a76a973eb26c1ea5b2de6141ffdba75a8d7b7f9800aed0bb
7
- data.tar.gz: a32a205c45a53d4f62d6118d348de3969989e1bafe16e9fbbc654fdcf5df711a30fc57db2c85edbdc56b0c5d10332e03947037b86e5700424dab280dfbeb85f6
6
+ metadata.gz: 9490216122e2b2c8e2fde9d294795e226ba7ffa2238b547372f2a5351897183d064da1cc8fdb13b77258fb1b2092d9e82ccf2df5d6144eb853da27eceb97bc06
7
+ data.tar.gz: 5cc9dd5e1a628dcbed7c1a6e07271c864668a2cac672ddc265d2bc1511d4568ad3bf1bc232d5866e005cab6ab4b02783eb3120ca96b161209865a091b148c6be
data/README.md CHANGED
@@ -27,15 +27,22 @@ class Side < Enum::Base
27
27
  end
28
28
  ```
29
29
 
30
- Now get a safely defined hash with the `enum` method with its `Symbol` or `String` type as argument. If there is no defined such hash `Enum::TokenNotFoundError` exception will be raised. And this is the **safety** - you will be noticed about the problem and fix it by introducing a new hash or fixing the source of the invalid hash. While others implementations of enums in Ruby (that I know) just silently ignore invalid values returning `nil` this one will raise the exception **always**. Example of usage:
30
+ Now get a safely defined key with the `enum` method with its `Symbol` or `String` type as argument. If there is no such key, `Enum::TokenNotFoundError` exception will be raised. And this is the **safety** - you will be noticed about the problem and fix it by introducing a new hash or fixing the source of the invalid hash. While others implementations of enums in Ruby (that I know) just silently ignore invalid values returning `nil` this one will raise the exception **always**. Example of usage:
31
31
 
32
32
  ```ruby
33
- Side.enum(:left) # => {:left => "my_left"}
34
- Side.enum('left') # => {:left => "my_left"}
33
+ Side.enum(:left) # => :left
34
+ Side.enum('left') # => :left
35
35
  Side.enum(:invalid) # => Enum::TokenNotFoundError: token 'invalid'' not found in Side
36
36
  Side.enum('invalid') # => Enum::TokenNotFoundError: token 'invalid'' not found in Side
37
37
  ```
38
38
 
39
+ To get the real enum, the hash representing the enum, use `real_enum` method :
40
+
41
+ ```ruby
42
+ Side.real_enum(:left) # => {:left => "my_left"}
43
+ Side.real_enum('left') # => {:left => "my_left"}
44
+ ```
45
+
39
46
  Get value of hash by token (String or Symbol):
40
47
 
41
48
  ```ruby
@@ -46,7 +46,7 @@ module Enum
46
46
  end
47
47
 
48
48
  def value(t)
49
- e = enum(t)
49
+ e = real_enum(t)
50
50
  e[t]
51
51
  end
52
52
 
@@ -1,3 +1,3 @@
1
1
  module Enum
2
- VERSION = '0.4.4'
2
+ VERSION = '0.4.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe-hash-enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - NETIKA real estate solution s.a.