Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow predefined_resource to accept additional attributes, that are m…

…erged with the predefiend attributes.
  • Loading branch information...
commit 051e1cb1e800af00889fdb03860ce0c8634267c9 1 parent 55d0476
Postmodern authored
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/dm-is-predefined/is/predefined.rb
7 lib/dm-is-predefined/is/predefined.rb
View
@@ -66,6 +66,9 @@ def predefined?(name)
# @param [Symbol, String] name
# The name of the pre-defined resource.
#
+ # @param [Hash{Symbol => Object}] extra_attributes
+ # Additional attributes to add to the predefined resource.
+ #
# @return [DataMapper::Resource]
# The pre-defined resource.
#
@@ -75,7 +78,7 @@ def predefined?(name)
#
# @since 0.2.1
#
- def predefined_resource(name)
+ def predefined_resource(name,extra_attributes={})
name = name.to_sym
attributes = self.predefined_attributes[name]
@@ -83,7 +86,7 @@ def predefined_resource(name)
raise(UnknownResource,"The resource '#{name}' was not predefined",caller)
end
- self.first_or_create(attributes)
+ self.first_or_create(attributes.merge(extra_attributes))
end
#
Please sign in to comment.
Something went wrong with that request. Please try again.