intellihash 0.1.1 → 0.1.2

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: 429b0a803c4c01cb64cfe602910d610e01b5566c947937de8c474dbee3c71018
4
- data.tar.gz: 82174f3ce70dbbec9a6b9c5807b942797a1e30307a3145dd72a92df490a5b184
3
+ metadata.gz: 1a0915c26f933f76e3c728a1b3d4bd024162636615386f5b20b5d4e13701f669
4
+ data.tar.gz: 28bfbc769a458c562d01be20128086f734ca2deec3945089aa253fff6da46f46
5
5
  SHA512:
6
- metadata.gz: 889c62ba1d243f33768b73764266d7f708782f479dac23cc9556e9e1a9c08af091fe0f25157f842457972c64ef70ac93bbde9eb1d61f1e0b9579239a9ed71ede
7
- data.tar.gz: 4cd3d0efd49c59df9bfe8b0638c1e713b05ae25d5e39d9866dbf5e7e8ef2d6383a33793c280735896fbe7b4f0f1666e9aa377939249e8b6178a144901fbf8a6e
6
+ metadata.gz: 4f9718e0b695518644045e439cd6425fb3411f2d52d241db42a5dc90e188b9db415564d2fe33a0c99555d16cf054fbbd0a98019f93a7b5ee4fe63a91c1b8e976
7
+ data.tar.gz: fbfe2e263d136ea67c370f643edac60479c32cfadf3e78fbac6b616d8125d48426d901456ec336b20bfa26b8c849f2bbe599ea1619840f8dd122a453eb3e1c34
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- intellihash (0.1.1)
4
+ intellihash (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -83,8 +83,8 @@ If you need to customize Intellihash, you may create a configuration:
83
83
 
84
84
  ```ruby
85
85
  Intellihash.configure do |config|
86
- config.enabled = true # (Boolean) Default: false
87
- config.default_format = :symbol # (Symbol) Default: :symbol
86
+ config.enabled = true # (Boolean) Default: false
87
+ config.default_format = :symbol # (Symbol) Default: :symbol
88
88
  config.intelligent_by_default = false # (Boolean) Default: false
89
89
  end
90
90
  ```
@@ -154,9 +154,9 @@ When configured correctly, they work even when the object contains arrays and ot
154
154
 
155
155
  ```ruby
156
156
  Intellihash.configure do |config|
157
- config.enabled = true
157
+ config.enabled = true
158
158
  config.intelligent_by_default = true
159
- config.default_format = :any
159
+ config.default_format = :any
160
160
  end
161
161
 
162
162
  intellihash = {
data/bin/console CHANGED
@@ -8,6 +8,7 @@ require 'byebug'
8
8
  Intellihash.configure do |config|
9
9
  config.enabled = true
10
10
  config.intelligent_by_default = true
11
+ config.default_format = :symbol
11
12
  end
12
13
 
13
14
  require 'irb'
@@ -3,6 +3,8 @@
3
3
  module Intellihash
4
4
  module Mixins
5
5
  def intelligent
6
+ return @intelligent if frozen?
7
+
6
8
  @intelligent = @intelligent.nil? ? Intellihash.configuration.intelligent_by_default : @intelligent
7
9
  end
8
10
 
@@ -21,6 +23,8 @@ module Intellihash
21
23
  end
22
24
 
23
25
  def default_format
26
+ return @default_format if frozen?
27
+
24
28
  @default_format ||= Intellihash.configuration.default_format
25
29
  end
26
30
 
@@ -28,6 +32,14 @@ module Intellihash
28
32
  @default_format = FORMATTER.member?(other) ? other : FORMATTER[:symbol]
29
33
  end
30
34
 
35
+ def freeze
36
+ # Touch these attributes if it hasn't already happened, ensure they're not nil
37
+ intelligent
38
+ default_format
39
+
40
+ super
41
+ end
42
+
31
43
  private
32
44
 
33
45
  FORMATTER = {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Intellihash
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intellihash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Porter