dot_hash 0.1.2 → 0.1.3
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.
- data/README.md +9 -2
- data/lib/dot_hash/properties.rb +2 -2
- data/lib/dot_hash/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# DotHash
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A very efficient gem that lets you use hashes as object properties. It is almost as fast as a plain Hash
|
|
4
|
+
since it's complexity is also linear, `O(n) # where N is the number of nested parents of the given property`.
|
|
4
5
|
|
|
5
6
|
## Installation
|
|
6
7
|
|
|
@@ -18,7 +19,13 @@ Or install it yourself as:
|
|
|
18
19
|
|
|
19
20
|
## Usage
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
```ruby
|
|
23
|
+
some_hash = {size: {height: 100, width: 500}, "color" => "red"}
|
|
24
|
+
properties = some_hash.to_properties
|
|
25
|
+
|
|
26
|
+
properties.size.height # returns 100, it is the same as some_hash[:size][:height]
|
|
27
|
+
properties.color # returns "red", it works with Strings and Symbol keys
|
|
28
|
+
```
|
|
22
29
|
|
|
23
30
|
## Contributing
|
|
24
31
|
|
data/lib/dot_hash/properties.rb
CHANGED
|
@@ -13,7 +13,7 @@ module DotHash
|
|
|
13
13
|
private
|
|
14
14
|
|
|
15
15
|
def fetch(key)
|
|
16
|
-
|
|
16
|
+
symbolize_key key
|
|
17
17
|
has_key? key and get_value key
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -29,7 +29,7 @@ module DotHash
|
|
|
29
29
|
hash[key] = self.class.new value
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
def
|
|
32
|
+
def symbolize_key(key)
|
|
33
33
|
return unless hash.has_key?(key.to_s)
|
|
34
34
|
hash[key.to_sym] = hash.delete key.to_s
|
|
35
35
|
end
|
data/lib/dot_hash/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dot_hash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -61,7 +61,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
61
61
|
version: '0'
|
|
62
62
|
segments:
|
|
63
63
|
- 0
|
|
64
|
-
hash: -
|
|
64
|
+
hash: -1382621053870240237
|
|
65
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
none: false
|
|
67
67
|
requirements:
|
|
@@ -70,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
70
70
|
version: '0'
|
|
71
71
|
segments:
|
|
72
72
|
- 0
|
|
73
|
-
hash: -
|
|
73
|
+
hash: -1382621053870240237
|
|
74
74
|
requirements: []
|
|
75
75
|
rubyforge_project:
|
|
76
76
|
rubygems_version: 1.8.24
|