Permalink
Browse files

Added predefined?.

  • Loading branch information...
1 parent 861977f commit 85821b2a9b6b47abe3df2e6b6190d933d45d0bba @postmodern committed Jul 16, 2011
Showing with 19 additions and 0 deletions.
  1. +15 −0 lib/dm-is-predefined/is/predefined.rb
  2. +4 −0 spec/integration/predefined_spec.rb
@@ -24,6 +24,21 @@ def predefined_names
end
#
+ # Determines if a resource was predefined.
+ #
+ # @param [Symbol, String] name
+ # The name of the predefined resource to search for.
+ #
+ # @return [Boolean]
+ # Specifies whether the resource was predefined.
+ #
+ # @since 0.4.0
+ #
+ def predefined?(name)
+ predefined_attributes.has_key?(name.to_sym)
+ end
+
+ #
# Finds or auto-creates the pre-defined resource with the given name.
#
# @param [Symbol, String] name
@@ -14,6 +14,10 @@
TestModel.predefined_names.should =~ [:test1, :test2]
end
+ it "should determine if a predefined resource was defined" do
+ TestModel.should be_predefined(:test2)
+ end
+
it "should be able to define resources of a Model" do
test1 = TestModel.test1

0 comments on commit 85821b2

Please sign in to comment.