strong_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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +18 -7
- data/lib/strong_hash.rb +5 -0
- data/lib/strong_hash/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0edad334738b3234e83015c9191e8de63b14e155b54a04c74c97908ec998009b
|
|
4
|
+
data.tar.gz: 107ee7d232da6818253475d51f923de779c2975be7e4e76c91410f4bf1af5d98
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 67d5800384acf94f7a76d17357db3e3bdd71e27d1289fca4c82a532784a98793a42dbc17db5290912fc0c7b49505f464f47b552ecc8f8c1d1b785299f56d288d
|
|
7
|
+
data.tar.gz: 45e7a7d649b609dac73310a0d0dcecb61132d4ad66c7b9b45655b2e954f028fb353ac238f6c21403b2cc77eeae68b3b74c657ce4818e0233d0e1521d5799ed7a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
# StrongHash
|
|
2
|
-
|
|
3
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/strong_hash`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
-
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
6
|
-
|
|
2
|
+
Let's you access Hash by dot operator. Just like calling a method on an object
|
|
7
3
|
## Installation
|
|
8
4
|
|
|
9
5
|
Add this line to your application's Gemfile:
|
|
@@ -21,8 +17,23 @@ Or install it yourself as:
|
|
|
21
17
|
$ gem install strong_hash
|
|
22
18
|
|
|
23
19
|
## Usage
|
|
20
|
+
```ruby
|
|
21
|
+
require 'strong_hash'
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
hash = {
|
|
24
|
+
name: 'Yask',
|
|
25
|
+
age: 23,
|
|
26
|
+
twitter: {
|
|
27
|
+
username: 'yask123'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
StrongHash.new(hash).name
|
|
32
|
+
> Yask
|
|
33
|
+
|
|
34
|
+
StrongHash.new(hash).twitter.username
|
|
35
|
+
> yask123
|
|
36
|
+
```
|
|
26
37
|
|
|
27
38
|
## Development
|
|
28
39
|
|
|
@@ -32,7 +43,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
|
32
43
|
|
|
33
44
|
## Contributing
|
|
34
45
|
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[
|
|
46
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[yask123]/strong_hash.
|
|
36
47
|
|
|
37
48
|
## License
|
|
38
49
|
|
data/lib/strong_hash.rb
CHANGED
|
@@ -4,6 +4,11 @@ require 'active_support/core_ext/hash/indifferent_access'
|
|
|
4
4
|
# by calling dot operator with key name
|
|
5
5
|
module StrongHash
|
|
6
6
|
def self.new(hash)
|
|
7
|
+
hash = hash.dup
|
|
8
|
+
hash.each do |key, val|
|
|
9
|
+
next unless val.is_a?(Hash)
|
|
10
|
+
hash[key] = new(val)
|
|
11
|
+
end
|
|
7
12
|
StrongHashFactory.new(hash)
|
|
8
13
|
end
|
|
9
14
|
|
data/lib/strong_hash/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: strong_hash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yask Srivastava
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-04-
|
|
11
|
+
date: 2018-04-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|