hash-dot 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hash-dot.rb +23 -6
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e58f1d55d55c806e95fbec7f84516b5c4ce921
|
4
|
+
data.tar.gz: a9f908143fb0c1f7e5b872d49c8780bfa03102a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 338d9809ed8a8c3b1a052680f428e88d66f3cd2b843df0df8cacdf6bd67133d83640f967dff22da1563424aeb52944a455e5aec062b1356a824157a6e641f1f1
|
7
|
+
data.tar.gz: 4888b9668b1057de5e375bc93f608c6b26a9d096971611ff1475b1ae22542fa64966d39d9826ec617b0609bfcff19eb6d2e1b74c4395ac01854939ac567f3a26
|
data/lib/hash-dot.rb
CHANGED
@@ -1,12 +1,29 @@
|
|
1
1
|
class Hash
|
2
|
+
def define_reader(key)
|
3
|
+
define_singleton_method(key.to_sym) do
|
4
|
+
if has_key?(key)
|
5
|
+
return self[key]
|
6
|
+
else
|
7
|
+
return self[key.to_sym]
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def define_writer(key)
|
13
|
+
define_singleton_method(key.to_sym) do |value|
|
14
|
+
self[key[0..-2].to_sym] = value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
2
18
|
def method_missing(method, *opts)
|
3
19
|
m = method.to_s
|
4
|
-
|
5
|
-
if
|
6
|
-
|
7
|
-
|
8
|
-
|
20
|
+
|
21
|
+
if m[-1] == '='
|
22
|
+
define_writer(m)
|
23
|
+
return self.send(method, *opts)
|
24
|
+
else
|
25
|
+
define_reader(m)
|
26
|
+
return self.send(method, *opts)
|
9
27
|
end
|
10
|
-
super
|
11
28
|
end
|
12
29
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash-dot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02
|
12
|
-
dependencies:
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
13
27
|
description: Adds the JavaScript dot notation for accessing hash keys to ruby, so
|
14
28
|
you can do my_hash.key1
|
15
29
|
email: BenjaminPorter86@gmail.com
|
@@ -38,8 +52,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
38
52
|
version: '0'
|
39
53
|
requirements: []
|
40
54
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.
|
55
|
+
rubygems_version: 2.2.2
|
42
56
|
signing_key:
|
43
57
|
specification_version: 4
|
44
58
|
summary: Adds the JavaScript hash syntax to ruby
|
45
59
|
test_files: []
|
60
|
+
has_rdoc:
|