swifter_enum 0.9.3 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c619ac4afac5bcbad7b49e421d04faa75bd558611297effa54c992a9509b7d7f
4
- data.tar.gz: 2fa59214a51e2417b6834362fcce525f5ca10a4fdf962261576252a0f6f6071f
3
+ metadata.gz: bc3b347202fe12dc7e9ee2c8fa4eb651c614ba0dad8e94ad1d7e8672ec4b277f
4
+ data.tar.gz: f93a2c4c0c713f89499ae18e80398757295ed15c4cb2b71b36c2254f121450d3
5
5
  SHA512:
6
- metadata.gz: 02d2882937c808e0c9c652ee7cf85cbea7a0d4425e33e7656718ac906bd475a2173ab5ec8d0f79d1a61b9ef8f634d76696429eac7500e7da33d039adb52a7038
7
- data.tar.gz: 5f4186f334a5f9fedb4e670a8f0dea82872e9d9733e96f44c0f9867438effa96d1408b85fa2f13d628487cf922ca5ee763f2c36e2c2dc963ce0eea431cf7fb1e
6
+ metadata.gz: 1d735965c2dd2a7db1e286285b3ec36871d3731f37fc824b11a0d1a7f7f5834b3de0be6568300df84cbbe13abcfc650b90a32a3dda42b8109df0b8d213cd6d6f
7
+ data.tar.gz: c733bb8c4abd3c67c7a98b22a8c27da3eff45f517ceab52e5938a59a691c6a406b0304914ef9028a3f6fce3830737c02dce9b57f6288c7ae0d6f0c52a7866e77
data/CHANGELOG.md CHANGED
@@ -7,4 +7,20 @@
7
7
 
8
8
  ## [0.9.1] - 2024-03-10
9
9
 
10
- - Fix use of options to use current syntax. Use prefix: true, rather than _prefix: true
10
+ - Fix use of options to use current syntax. Use prefix: true, rather than _prefix: true
11
+
12
+ ## [0.9.2]
13
+
14
+ - Allow String keys
15
+
16
+ ## [0.9.3]
17
+
18
+ - Fix generator & freeze values
19
+
20
+ ## [0.9.4]
21
+
22
+ - Add 'all_cases'
23
+
24
+ ## [0.9.5]
25
+
26
+ - Fix translation method when value is nil (returns nil)
@@ -15,6 +15,10 @@ module SwifterEnum
15
15
  end
16
16
  end
17
17
 
18
+ def all_cases
19
+ @values.keys.map { |key| new(key) }
20
+ end
21
+
18
22
  private
19
23
 
20
24
  def validate_array_elements!(array)
@@ -24,7 +28,7 @@ module SwifterEnum
24
28
  end
25
29
  end
26
30
 
27
- attr_reader :value
31
+ attr_accessor :value
28
32
 
29
33
  def initialize(value)
30
34
  @value = value&.to_sym
@@ -39,11 +43,13 @@ module SwifterEnum
39
43
  end
40
44
 
41
45
  def t
42
- I18n.t("swifter_enum.#{self.class.name.demodulize.underscore}.#{@value}")
46
+ return nil if value.nil?
47
+
48
+ I18n.t("swifter_enum.#{self.class.name.demodulize.underscore}.#{value}")
43
49
  end
44
50
 
45
51
  def to_s
46
- @value
52
+ value.to_s
47
53
  end
48
54
 
49
55
  def self.all
@@ -1,5 +1,11 @@
1
1
  require "active_support/concern"
2
2
 
3
+ # Adds methods to Rails Models
4
+ # swifter_enum
5
+ # model.enum_attribute (getter/setter)
6
+ # model.enum_attribute_raw (getter/setter to underlying enum)
7
+ # model.enum_attribute_raws
8
+
3
9
  module SwifterEnum
4
10
  extend ActiveSupport::Concern
5
11
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SwifterEnum
4
- VERSION = "0.9.3"
4
+ VERSION = "0.9.5"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swifter_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Jonson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-12 00:00:00.000000000 Z
11
+ date: 2024-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord