rails_string_enum 0.3.2 → 0.4.0

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
  SHA1:
3
- metadata.gz: 491452602fcc9c51c9f28ce9be8ae990e18c5756
4
- data.tar.gz: e7c158a12049329fa13d028d11775eb5353dd58f
3
+ metadata.gz: 6ffcc890f6854d7a23813243d6497693855a9708
4
+ data.tar.gz: 466bc0454e0e761ead3fc71a58062b523cd4f281
5
5
  SHA512:
6
- metadata.gz: d33b9ef6e627827b75cc01f3993d304b66ba39a73f64d1c9edb9dce02501b13737434c846d3fb43062b0bcbe19072916867eb4692dd6530fc7892cd81fec7b9d
7
- data.tar.gz: 8cd6632a4df253f70d5b4b4a56969482df72ba3c914e37c2b2222756960d847c4290ff374e4cbc4053429ff2371158f9d054db847e7012c630817ebf960b566d
6
+ metadata.gz: 2e3323198397858722fd5a24a24c6b11c79803ec2aca9c09ad2b101956e614f23a94038fe4361718bc230decb55df27cefa1410495b0c959d15773b53d44838f
7
+ data.tar.gz: dbe2ad31026fd97e4cb99de452e7ab4e0832034f61ff7f632897b69c3a3ac4c01ed2a70f3022a8dbe4f67f8124132a54fe8339802d932fb339d1c6c1e10df1d4
data/README.md CHANGED
@@ -86,6 +86,10 @@ Product::COLORS # => ["red", "green", "yellow"]
86
86
  Product::RED # => "red"
87
87
  Product::GREEN # => "green"
88
88
 
89
+ # for combinations constants to array, using `__` for split it
90
+ Product::RED__GREEN__YELLOW #=> ["red", "green", "yellow"]
91
+ Product::RED__GREEN__BLABLA #=> NameError: uninitialized constant Product::BLABLA
92
+
89
93
  @product = Product.new
90
94
  @product.color_i18n # => nil
91
95
  @product.red!
@@ -127,4 +127,15 @@ module RailsStringEnum
127
127
  %Q{::I18n.t(enum_label, scope: "enums.#{part_scope}", default: enum_label)}
128
128
  end
129
129
 
130
+
131
+ # for combinations constants to array, using `__` for split it
132
+ # Product::RED__GREEN__YELLOW #=> ["red", "green", "yellow"]
133
+ # Product::RED__GREEN__BLABLA #=> NameError: uninitialized constant Product::BLABLA
134
+ def const_missing(name)
135
+ name_s = name.to_s
136
+ return super unless name_s.include?('__')
137
+
138
+ const_set name_s, name_s.split('__').map { |i| const_get(i) }
139
+ end
140
+
130
141
  end
@@ -1,3 +1,3 @@
1
1
  module RailsStringEnum
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_string_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ermolaev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-12 00:00:00.000000000 Z
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler