intellihash 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/bin/console +1 -0
- data/lib/intellihash/mixins.rb +12 -0
- data/lib/intellihash/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a0915c26f933f76e3c728a1b3d4bd024162636615386f5b20b5d4e13701f669
|
4
|
+
data.tar.gz: 28bfbc769a458c562d01be20128086f734ca2deec3945089aa253fff6da46f46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f9718e0b695518644045e439cd6425fb3411f2d52d241db42a5dc90e188b9db415564d2fe33a0c99555d16cf054fbbd0a98019f93a7b5ee4fe63a91c1b8e976
|
7
|
+
data.tar.gz: fbfe2e263d136ea67c370f643edac60479c32cfadf3e78fbac6b616d8125d48426d901456ec336b20bfa26b8c849f2bbe599ea1619840f8dd122a453eb3e1c34
|
data/Gemfile.lock
CHANGED
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
|
87
|
-
config.default_format
|
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
|
157
|
+
config.enabled = true
|
158
158
|
config.intelligent_by_default = true
|
159
|
-
config.default_format
|
159
|
+
config.default_format = :any
|
160
160
|
end
|
161
161
|
|
162
162
|
intellihash = {
|
data/bin/console
CHANGED
data/lib/intellihash/mixins.rb
CHANGED
@@ -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 = {
|
data/lib/intellihash/version.rb
CHANGED