galetahub-enum_field 0.5.1 → 0.5.2

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
- SHA1:
3
- metadata.gz: 6aecc946fb32aa9197932e9ff1264bbf06cd19ef
4
- data.tar.gz: 58f8f65ee968672a7b1678819b18612a7faec2ac
2
+ SHA256:
3
+ metadata.gz: bca2cd26a65aed9da78b857dfa411cb9fadb58f4a81b9d1210e647415b54888e
4
+ data.tar.gz: cb795d43547eaed7c63f8a876aa72ebcfa3630cbb13c42fc60357853f853f762
5
5
  SHA512:
6
- metadata.gz: 2a9241a8594e8f55df86dd494cf288075e2865cb47672f537f675bd0c3e982b38c764bfa9b916dd69a67bf530f43f62274c766a04d147f87abf762d5a8eb8616
7
- data.tar.gz: 065c0d729c5ecd8ef57b5673eb7802a851ad96c1a6c89f4b130edf3f808fb1440e681b3694bf1b749fc150a202f3506073de43387c7e6272817379771726cd47
6
+ metadata.gz: 8440864257d9c15d30b7098eaaf731ddac95c820c3e98e6fc3a9d4aedcd24e6267ff169b399e6c7d5f8a927713afea380b3b084e1a5aa381bfaed0153bca28a4
7
+ data.tar.gz: dd780b0a27aff83db43819b5f5f9922277428c07eab20824eebdec295d84d79500a284deb30abbf43965b701596fcb14f075302771cc7e54e1ab19943fbe3ade
data/README.md CHANGED
@@ -61,11 +61,14 @@ user.role = Role.manager
61
61
  user.role_id == Role.manager.id # will be true
62
62
 
63
63
  Role.manager.name # :manager
64
- user.role.name # :manager
64
+ user.role.name # :manager
65
+
66
+ Role.names # [:admin, :manager, :employee]
67
+ Role.ids # [1, 2, 3]
65
68
 
66
69
  User.first.role.id == User.first.role_id # will be true
67
70
 
68
- Role[:manager] == Role.manager # will be true
71
+ Role[:manager] == Role.manager # will be true
69
72
  Role['manager'] == Role.manager # will be true
70
73
 
71
74
  instance = Role[:employee]
@@ -14,7 +14,7 @@ module EnumField
14
14
 
15
15
  def member(name, options = {})
16
16
  unique_name = normalize_name(name)
17
- @members[unique_name] = create_new_object(unique_name, options)
17
+ @members[unique_name] ||= create_new_object(unique_name, options)
18
18
  end
19
19
 
20
20
  def all
@@ -17,7 +17,7 @@ module EnumField
17
17
  module ClassMethods
18
18
  def define_enum(options = {}, &block)
19
19
  @enum_builder ||= EnumField::Builder.new(self, options)
20
- @enum_builder.instance_exec(&block)
20
+ @enum_builder.instance_exec(&block) unless @enum_builder.frozen?
21
21
 
22
22
  EnumField::Builder::METHODS.each do |method|
23
23
  define_singleton_method method do |*args, &method_block|
@@ -1,3 +1,3 @@
1
1
  module EnumField
2
- VERSION = '0.5.1'.freeze
2
+ VERSION = '0.5.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: galetahub-enum_field
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Galeta
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-05-03 00:00:00.000000000 Z
12
+ date: 2018-07-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.6.12
109
+ rubygems_version: 2.7.6
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Enumerated attributes for any ruby class aka Active Record