dot_hash 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dot_hash/properties.rb +4 -4
- data/lib/dot_hash/settings.rb +2 -2
- data/lib/dot_hash/version.rb +1 -1
- data/test/dot_hash/properties_test.rb +6 -0
- metadata +3 -3
data/lib/dot_hash/properties.rb
CHANGED
@@ -7,9 +7,9 @@ module DotHash
|
|
7
7
|
@hash = hash
|
8
8
|
end
|
9
9
|
|
10
|
-
def method_missing(key)
|
10
|
+
def method_missing(key, *args, &block)
|
11
11
|
symbolize_key key
|
12
|
-
has_key?(key) ? get_value(key) : super
|
12
|
+
has_key?(key) ? get_value(key, *args, &block) : super
|
13
13
|
end
|
14
14
|
|
15
15
|
def respond_to?(key)
|
@@ -28,9 +28,9 @@ module DotHash
|
|
28
28
|
hash.has_key?(key.to_sym) or hash.respond_to?(key)
|
29
29
|
end
|
30
30
|
|
31
|
-
def get_value(key)
|
31
|
+
def get_value(key, *args, &block)
|
32
32
|
key = key.to_sym
|
33
|
-
value = hash.fetch(key) { hash.send(key) }
|
33
|
+
value = hash.fetch(key) { hash.send(key, *args, &block) }
|
34
34
|
return value unless value.is_a?(Hash)
|
35
35
|
hash[key] = self.class.new value
|
36
36
|
end
|
data/lib/dot_hash/settings.rb
CHANGED
data/lib/dot_hash/version.rb
CHANGED
@@ -25,6 +25,12 @@ module DotHash
|
|
25
25
|
it "gets all values from a given property" do
|
26
26
|
properties.values.must_equal ["15", 100]
|
27
27
|
end
|
28
|
+
|
29
|
+
it "responds to a block method" do
|
30
|
+
properties.map do |key, value|
|
31
|
+
[key, value]
|
32
|
+
end.must_equal [[:speed, "15"], ["power", 100]]
|
33
|
+
end
|
28
34
|
end
|
29
35
|
|
30
36
|
describe "with a nested hash" do
|
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.2.
|
4
|
+
version: 0.2.5
|
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: 4595175337446195282
|
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: 4595175337446195282
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
81
|
rubygems_version: 1.8.24
|