zilkey-active_hash 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/active_hash.gemspec +1 -1
- data/lib/active_hash/base.rb +2 -3
- data/spec/active_hash/base_spec.rb +9 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
data/active_hash.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{active_hash}
|
5
|
-
s.version = "0.6.
|
5
|
+
s.version = "0.6.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Jeff Dean", "Mike Dalessio", "Corey Innis", "Peter Jaros"]
|
data/lib/active_hash/base.rb
CHANGED
@@ -65,10 +65,9 @@ module ActiveHash
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def method_missing(method_name, *args)
|
68
|
-
|
69
|
-
|
70
|
-
return super unless config
|
68
|
+
return super unless respond_to? method_name
|
71
69
|
|
70
|
+
config = configuration_for_custom_finder(method_name)
|
72
71
|
attribute_pairs = config[:fields].zip(args)
|
73
72
|
matches = all.select { |base| attribute_pairs.all? { |field, value| base.send(field) == value } }
|
74
73
|
config[:all?] ? matches : matches.first
|
@@ -219,7 +219,7 @@ describe ActiveHash, "Base" do
|
|
219
219
|
|
220
220
|
describe "custom finders" do
|
221
221
|
before do
|
222
|
-
Country.fields :name, :monarch
|
222
|
+
Country.fields :name, :monarch, :language
|
223
223
|
|
224
224
|
# Start ids above 4 lest we get nil and think it's an AH::Base model with id=4.
|
225
225
|
Country.data = [
|
@@ -294,6 +294,14 @@ describe ActiveHash, "Base" do
|
|
294
294
|
Country.find_by_name_and_monarch("US", "The Crown of England").should be_nil
|
295
295
|
end
|
296
296
|
end
|
297
|
+
|
298
|
+
describe "for fields the class doesn't have" do
|
299
|
+
it "raises a NoMethodError" do
|
300
|
+
lambda {
|
301
|
+
Country.find_by_name_and_shoe_size("US", 10)
|
302
|
+
}.should raise_error(NoMethodError, "undefined method `find_by_name_and_shoe_size' for Country:Class")
|
303
|
+
end
|
304
|
+
end
|
297
305
|
end
|
298
306
|
|
299
307
|
describe "find_all_by_<field_one>_and_<field_two>" do
|