Skip to content
Browse files

Do not override the behavior of get.

  • Loading branch information...
1 parent e3edd5f commit 7454ca0675c044f3ac2da995d87a1d5d41502c03 @postmodern committed
Showing with 6 additions and 45 deletions.
  1. +6 −36 lib/dm-is-predefined/is/predefined.rb
  2. +0 −9 spec/integration/predefined_spec.rb
View
42 lib/dm-is-predefined/is/predefined.rb
@@ -172,11 +172,15 @@ def predefined_resource(name)
# Could not find a predefined resource that shared all of the
# desired attributes.
#
- # @since 0.4.0
+ # @deprecated
+ # Will be removed in 1.0.0. Instead, search {#predefined_attributes}
+ # directly.
+ #
+ # @since 0.2.1
#
# @api public
#
- def first_predefined_resource(query={})
+ def predefined_resource_with(query={})
if (resource = first(query))
return resource
end
@@ -194,40 +198,6 @@ def first_predefined_resource(query={})
raise(UnknownResource,"Could not find a predefined resource which shared the given attributes")
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.
- #
- # @param [Symbol, Object] key
- # The name of the predefined resource or primary-key of a
- # pre-existing resource.
- #
- # @return [DataMapper::Resource, nil]
- # The matching resource.
- #
- # @since 0.4.0
- #
- # @api public
- #
- def get(key)
- if key.kind_of?(Symbol)
- predefined_resource(key)
- else
- super(key)
- end
- end
-
protected
#
View
9 spec/integration/predefined_spec.rb
@@ -108,13 +108,4 @@
}.should raise_error(DataMapper::Is::Predefined::UnknownResource)
end
end
-
- describe "#get" do
- it "should allow querying predefined resources by name" do
- test2 = TestModel.get(:test2)
-
- test2.name.should == 'test2'
- test2.number.should == 2
- end
- end
end

0 comments on commit 7454ca0

Please sign in to comment.
Something went wrong with that request. Please try again.