lib/gummi/repository_layer/repository.rb in gummi-0.2.3 vs lib/gummi/repository_layer/repository.rb in gummi-0.3.0
- old
+ new
@@ -6,39 +6,35 @@
included do
include Repobahn::Repository
after_conversion :set_id_and_version
end
- module ClassMethods
+ def get(id)
+ document = db_class.get id
+ db_instance_to_entity document if document
+ end
- def get(id)
- document = db_class.get id
- db_instance_to_entity document if document
- end
+ def search(options = {}, &block)
+ search = db_class.new_filtered_search(options)
+ yield search if block_given?
+ Repository::Result.new search.execute, self
+ end
- def search(options = {}, &block)
- search = db_class.new_filtered_search(options)
- yield search if block_given?
- Repository::Result.new search.execute, self
- end
+ def raw_search(options = {}, &block)
+ search = db_class.new_raw_search(options)
+ yield search if block_given?
+ Repository::Result.new search.execute, self
+ end
- def raw_search(options = {}, &block)
- search = db_class.new_raw_search(options)
- yield search if block_given?
- Repository::Result.new search.execute, self
- end
+ def overwrite(entity)
+ return false unless entity.valid?
+ document = db_class.new(entity.attributes)
+ document.overwrite
+ end
- def overwrite(entity)
- return false unless entity.valid?
- document = db_class.new(entity.attributes)
- document.overwrite
- end
-
- def set_id_and_version(entity, db_instance)
- entity.id = db_instance.id
- entity.version = db_instance.version
- end
-
+ def set_id_and_version(entity, db_instance)
+ entity.id = db_instance.id
+ entity.version = db_instance.version
end
end
end
end