intellihash 0.1.0 → 0.1.1

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: 17ac847b242baeffdc96ca1bb5b53c352b151834f69982221d30d73048b0ae35
4
- data.tar.gz: e1f386d85a69f2af333b1c2c85bba7f66e7d2977bfd0fab69aa19174a8e22cd7
3
+ metadata.gz: 429b0a803c4c01cb64cfe602910d610e01b5566c947937de8c474dbee3c71018
4
+ data.tar.gz: 82174f3ce70dbbec9a6b9c5807b942797a1e30307a3145dd72a92df490a5b184
5
5
  SHA512:
6
- metadata.gz: 2dcc030b8a4013d1ed190eafb7ce8ef0c075db1ab77dc254524f7594addcbfad5c717ff8af198fdaa09a07b90548719ffefc40ae1e206d4601f4995215238e26
7
- data.tar.gz: 8145467934645236a1819456705cc45e1d08d2be75518af8db5a0027849699b94965735b5ab9b1158744ff03de99a1ca9374deeb889280dc2bb848ee660d24f2
6
+ metadata.gz: 889c62ba1d243f33768b73764266d7f708782f479dac23cc9556e9e1a9c08af091fe0f25157f842457972c64ef70ac93bbde9eb1d61f1e0b9579239a9ed71ede
7
+ data.tar.gz: 4cd3d0efd49c59df9bfe8b0638c1e713b05ae25d5e39d9866dbf5e7e8ef2d6383a33793c280735896fbe7b4f0f1666e9aa377939249e8b6178a144901fbf8a6e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- intellihash (0.1.0)
4
+ intellihash (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A fast implementation of hashes as objects, benchmarked against OpenStruct. It allows chaining hash attributes as method calls instead of standard hash syntax.
4
4
 
5
- Since an Intellihash extends the native Ruby `Hash`, this means instantiating a new smart hash is just as fast as a normal hash, _and_ you retain the ability to call all the normal instance methods on it.
5
+ Since an Intellihash extends the native Ruby `Hash`, this means instantiating a new intelligent hash is just as fast as a normal hash, _and_ you retain the ability to call all the normal instance methods on it.
6
6
 
7
7
  ```ruby
8
8
  intellihash = {
@@ -56,7 +56,7 @@ Creating an Intellihash is approximately 5x faster than instantiating an OpenStr
56
56
  ```
57
57
  user system total real
58
58
  OpenStruct: 4.046875 0.906250 4.953125 ( 4.979611)
59
- Intellihash: 0.828125 0.125000 0.953125 ( 0.956110)
59
+ Intellihash: 0.828125 0.125000 0.953125 ( 0.956110)
60
60
  ```
61
61
 
62
62
  See [Testing Performance](#testing-performance) for details on running benchmarks.
@@ -85,7 +85,7 @@ If you need to customize Intellihash, you may create a configuration:
85
85
  Intellihash.configure do |config|
86
86
  config.enabled = true # (Boolean) Default: false
87
87
  config.default_format = :symbol # (Symbol) Default: :symbol
88
- config.smart_by_default = false # (Boolean) Default: false
88
+ config.intelligent_by_default = false # (Boolean) Default: false
89
89
  end
90
90
  ```
91
91
 
@@ -99,9 +99,9 @@ end
99
99
  - **default_format**
100
100
  - Valid values: `:sym, :symbol, :str, :string, :any`
101
101
  - This determines the default storage and retrieval options
102
- - **smart_by_default**
103
- - Whether newly created hashes are smart
104
- - When `false`, new hashes can still be converted to smart hashes via `hash.is_smart = true` or `hash.to_intellihash!`
102
+ - **intelligent_by_default**
103
+ - Whether newly created hashes are intelligent
104
+ - When `false`, new hashes can still be converted to intelligent hashes via `hash.is_intelligent = true` or `hash.to_intellihash!`
105
105
 
106
106
  ### Rails
107
107
 
@@ -111,21 +111,21 @@ Place the above configuration in an initializer (such as `config/initializers/in
111
111
 
112
112
  ### Instantiating an Intellihash
113
113
 
114
- If you've configured Intellihash `smart_by_default = true`, you need to do nothing else as _all_ new hashes are Intellihashes.
114
+ If you've configured Intellihash `intelligent_by_default = true`, you need to do nothing else as _all_ new hashes are Intellihashes.
115
115
 
116
116
  However, if you prefer not to use this configuration, you can create an Intellihash from any existing hash:
117
117
 
118
118
  ```ruby
119
119
  hash = { foo: :bar }
120
120
 
121
- hash.is_smart?
121
+ hash.is_intelligent?
122
122
  #=> false
123
123
 
124
- hash.is_smart = true
124
+ hash.is_intelligent = true
125
125
  # or
126
126
  hash.to_intellihash!
127
127
 
128
- hash.is_smart?
128
+ hash.is_intelligent?
129
129
  #=> true
130
130
  ```
131
131
 
@@ -155,7 +155,7 @@ When configured correctly, they work even when the object contains arrays and ot
155
155
  ```ruby
156
156
  Intellihash.configure do |config|
157
157
  config.enabled = true
158
- config.smart_by_default = true
158
+ config.intelligent_by_default = true
159
159
  config.default_format = :any
160
160
  end
161
161
 
data/bin/console CHANGED
@@ -6,8 +6,8 @@ require 'intellihash'
6
6
  require 'byebug'
7
7
 
8
8
  Intellihash.configure do |config|
9
- config.enabled = true
10
- config.smart_by_default = true
9
+ config.enabled = true
10
+ config.intelligent_by_default = true
11
11
  end
12
12
 
13
13
  require 'irb'
@@ -4,7 +4,7 @@ module Intellihash
4
4
  module Callbacks
5
5
  # https://ruby-doc.org/core-3.0.1/Hash.html
6
6
  #
7
- # Methods that return a copy of :self: need this callback to populate :smart: from :self:
7
+ # Methods that return a copy of :self: need this callback to populate :intelligent: from :self:
8
8
  AFTER_CALLBACK_TARGETS = %i[
9
9
  compact
10
10
  invert
@@ -24,7 +24,7 @@ module Intellihash
24
24
  result = super(*args, &block)
25
25
 
26
26
  # Register :after: callbacks
27
- result.is_smart = smart if result.respond_to?(:is_smart=) && !result.frozen?
27
+ result.is_intelligent = intelligent if result.respond_to?(:is_intelligent=) && !result.frozen?
28
28
 
29
29
  result
30
30
  end
@@ -25,13 +25,13 @@ module Intellihash
25
25
  end
26
26
 
27
27
  class Configuration
28
- attr_accessor :enabled, :smart_by_default
28
+ attr_accessor :enabled, :intelligent_by_default
29
29
  attr_reader :default_format
30
30
 
31
31
  def initialize
32
- @default_format = :symbol
33
- @enabled = false
34
- @smart_by_default = false
32
+ @default_format = :symbol
33
+ @enabled = false
34
+ @intelligent_by_default = false
35
35
  end
36
36
 
37
37
  def default_format=(other)
@@ -2,22 +2,22 @@
2
2
 
3
3
  module Intellihash
4
4
  module Mixins
5
- def smart
6
- @smart = @smart.nil? ? Intellihash.configuration.smart_by_default : @smart
5
+ def intelligent
6
+ @intelligent = @intelligent.nil? ? Intellihash.configuration.intelligent_by_default : @intelligent
7
7
  end
8
8
 
9
- def is_smart=(value)
9
+ def is_intelligent=(value)
10
10
  # Ensure this is a boolean
11
- @smart = value == true
11
+ @intelligent = value == true
12
12
  end
13
13
 
14
14
  def to_intellihash
15
- @smart = true
15
+ @intelligent = true
16
16
  self
17
17
  end
18
18
 
19
- def is_smart?
20
- smart
19
+ def is_intelligent?
20
+ intelligent
21
21
  end
22
22
 
23
23
  def default_format
@@ -39,7 +39,7 @@ module Intellihash
39
39
  }.freeze
40
40
 
41
41
  def method_missing(method_name, *args, **kwargs, &block)
42
- super unless respond_to?(:is_smart?) && is_smart?
42
+ super unless respond_to?(:is_intelligent?) && is_intelligent?
43
43
 
44
44
  if method_name[-1] == '='
45
45
  send(:store, method_name[0, method_name.size - 1].send(key_store_as), args.first)
@@ -53,7 +53,7 @@ module Intellihash
53
53
  end
54
54
 
55
55
  def respond_to_missing?(*)
56
- is_smart? ? true : super
56
+ is_intelligent? ? true : super
57
57
  end
58
58
 
59
59
  def key_store_as
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Intellihash
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Porter