Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

DRYing `update` and `create` in Adapter::Rails

  • Loading branch information...
commit 30417b06fe7cdb90b172c13c31be07ab04d1103e 1 parent 1dff850
Alex Serebryakov serebryakov authored
Showing with 9 additions and 6 deletions.
  1. +9 −6 lib/lib/adapters/rails.rb
15 lib/lib/adapters/rails.rb
View
@@ -59,24 +59,27 @@ def reload(instance)
# [-]
##
def update(instance)
- query = RDFMapper::Scope::Query.new(instance.class, :conditions => instance.properties)
- Query.new(query, @options).update
+ Query.new(default_query(instance), @options).update
end
##
# [-]
##
def create(instance)
- query = RDFMapper::Scope::Query.new(instance.class, :conditions => instance.properties)
- Query.new(query, @options).create
+ Query.new(default_query(instance), @options).create
end
private
- def check_for_rails_id(instance)
+ ##
+ # [-]
+ ##
+ def default_query(instance) #nodoc
+ conditions = {}.merge(instance.properties).merge(instance.foreign_keys)
+ RDFMapper::Scope::Query.new(instance.class, :conditions => conditions)
end
-
+
class Query
include RDFMapper::Logger
Please sign in to comment.
Something went wrong with that request. Please try again.