core_extended 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,12 +32,8 @@ class Hash
32
32
  end.uniq
33
33
  end
34
34
 
35
- def methods(*args)
36
- keys.flat_map{ |k| self.class.inflections(k).map(&:to_sym) }.uniq.concat(super)
37
- end
38
-
39
- def respond_to?(method, *args)
40
- super || methods.include?(method.to_sym)
35
+ def inflections
36
+ keys.flat_map{ |k| self.class.inflections(k).map(&:to_sym) }.uniq
41
37
  end
42
38
 
43
39
  def get(key)
@@ -55,7 +51,7 @@ class Hash
55
51
  end
56
52
 
57
53
  def method_missing(method, *args, &block)
58
- return get(method) if respond_to?(method.to_sym)
54
+ return get(method) if inflections.include?(method.to_sym)
59
55
  super
60
56
  end
61
57
 
@@ -1,3 +1,3 @@
1
1
  module CoreExtended
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
data/spec/hash_spec.rb CHANGED
@@ -29,16 +29,8 @@ describe Hash do
29
29
  hash.get('keyName3').must_be_nil
30
30
  end
31
31
 
32
- it 'Methods for all keys' do
33
- hash.methods.must_include :keyName1
34
- hash.methods.must_include :keyName2
35
- hash.methods.wont_include :keyName3
36
- end
37
-
38
- it 'Respond to all keys' do
39
- hash.must_be :respond_to?, :keyName1
40
- hash.must_be :respond_to?, :keyName2
41
- hash.wont_be :respond_to?, :keyName3
32
+ it 'Inflections for all keys' do
33
+ hash.inflections.must_equal_contents [:keyName1, :keyName2]
42
34
  end
43
35
 
44
36
  it 'Key method accessors' do
@@ -78,26 +70,8 @@ describe Hash do
78
70
  hash.get('key_name3').must_equal 3
79
71
  end
80
72
 
81
- it 'Methods for all keys' do
82
- hash.methods.must_include :keyName1
83
- hash.methods.must_include :key_name1
84
-
85
- hash.methods.must_include :KeyName2
86
- hash.methods.must_include :key_name2
87
-
88
- hash.methods.wont_include :keyName3
89
- hash.methods.must_include :key_name3
90
- end
91
-
92
- it 'Respond to all keys' do
93
- hash.must_be :respond_to?, :keyName1
94
- hash.must_be :respond_to?, :key_name1
95
-
96
- hash.must_be :respond_to?, :KeyName2
97
- hash.must_be :respond_to?, :key_name2
98
-
99
- hash.wont_be :respond_to?, :keyName3
100
- hash.must_be :respond_to?, :key_name3
73
+ it 'Inflections for all keys' do
74
+ hash.inflections.must_equal_contents [:keyName1, :key_name1, :KeyName2, :key_name2, :key_name3]
101
75
  end
102
76
 
103
77
  it 'Key method accessors' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core_extended
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-20 00:00:00.000000000 Z
12
+ date: 2013-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -174,12 +174,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
174
174
  - - ! '>='
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
+ segments:
178
+ - 0
179
+ hash: -2236399031548685911
177
180
  required_rubygems_version: !ruby/object:Gem::Requirement
178
181
  none: false
179
182
  requirements:
180
183
  - - ! '>='
181
184
  - !ruby/object:Gem::Version
182
185
  version: '0'
186
+ segments:
187
+ - 0
188
+ hash: -2236399031548685911
183
189
  requirements: []
184
190
  rubyforge_project:
185
191
  rubygems_version: 1.8.25