dot_hash 0.2.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dot_hash/properties.rb +4 -10
- data/lib/dot_hash/version.rb +1 -1
- metadata +3 -3
data/lib/dot_hash/properties.rb
CHANGED
@@ -8,26 +8,25 @@ module DotHash
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def method_missing(key, *args, &block)
|
11
|
-
symbolize_key key
|
12
11
|
has_key?(key) ?
|
13
12
|
execute(key, *args, &block) :
|
14
13
|
super(key, *args, &block)
|
15
14
|
end
|
16
15
|
|
17
16
|
def respond_to?(key)
|
18
|
-
symbolize_key key
|
19
17
|
has_key?(key) or super(key)
|
20
18
|
end
|
21
19
|
|
22
20
|
def [](key)
|
23
|
-
symbolize_key key
|
24
21
|
get_value(key)
|
25
22
|
end
|
26
23
|
|
27
24
|
private
|
28
25
|
|
29
26
|
def has_key?(key)
|
30
|
-
hash.has_key?(key.to_sym) or
|
27
|
+
hash.has_key?(key.to_sym) or
|
28
|
+
hash.has_key?(key.to_s) or
|
29
|
+
hash.respond_to?(key)
|
31
30
|
end
|
32
31
|
|
33
32
|
def execute(key, *args, &block)
|
@@ -37,15 +36,10 @@ module DotHash
|
|
37
36
|
end
|
38
37
|
|
39
38
|
def get_value(key)
|
40
|
-
key = key.to_sym
|
39
|
+
key = hash.has_key?(key.to_s) ? key.to_s : key.to_sym
|
41
40
|
value = hash[key]
|
42
41
|
return value unless value.is_a?(Hash)
|
43
42
|
hash[key] = self.class.new value
|
44
43
|
end
|
45
|
-
|
46
|
-
def symbolize_key(key)
|
47
|
-
return unless hash.has_key?(key.to_s)
|
48
|
-
hash[key.to_sym] = hash.delete key.to_s
|
49
|
-
end
|
50
44
|
end
|
51
45
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -66,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
segments:
|
68
68
|
- 0
|
69
|
-
hash: -
|
69
|
+
hash: -618655920888708363
|
70
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
71
|
none: false
|
72
72
|
requirements:
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
version: '0'
|
76
76
|
segments:
|
77
77
|
- 0
|
78
|
-
hash: -
|
78
|
+
hash: -618655920888708363
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
81
|
rubygems_version: 1.8.24
|