Permalink
Browse files

Renamed predefined_resource_with to first_predefined_resource.

  • Loading branch information...
1 parent 9bd028e commit 5668a4ea53faf07e69e5e3d0eceb139f31daed8f @postmodern committed Jul 24, 2011
Showing with 15 additions and 4 deletions.
  1. +13 −2 lib/dm-is-predefined/is/predefined.rb
  2. +2 −2 spec/integration/predefined_spec.rb
@@ -106,9 +106,9 @@ def predefined_resource(name)
# Could not find a predefined resource that shared all of the
# desired attributes.
#
- # @since 0.2.1
+ # @since 0.4.0
#
- def predefined_resource_with(query={})
+ def first_predefined_resource(query={})
if (resource = first(query))
return resource
end
@@ -127,6 +127,17 @@ def predefined_resource_with(query={})
end
#
+ # @since 0.2.1
+ #
+ # @deprecated
+ # Will be removed in 1.0.0. Please use {#first_predefined_resource}
+ # instead.
+ #
+ def predefined_resource_with(query={})
+ first_predefined_resource(query)
+ end
+
+ #
# Allows transparently getting predefined resources, alongwith
# existing resources.
#
@@ -62,14 +62,14 @@
describe "predefined_resource_with" do
it "should find resources based on attributes they share" do
- test2 = TestModel.predefined_resource_with(:name => 'test2', :number => 2)
+ test2 = TestModel.first_predefined_resource(:name => 'test2', :number => 2)
test2.name.should == 'test2'
end
it "should raise UnknownResource if no resource shares any attribute values" do
lambda {
- TestModel.predefined_resource_with(:number => 100, :optional => 'bla')
+ TestModel.first_predefined_resource(:number => 100, :optional => 'bla')
}.should raise_error(DataMapper::Is::Predefined::UnknownResource)
end
end

0 comments on commit 5668a4e

Please sign in to comment.