lib/ruote/storage/composite_storage.rb in ruote-2.1.11 vs lib/ruote/storage/composite_storage.rb in ruote-2.2.0

- old
+ new

@@ -1,7 +1,7 @@ #-- -# Copyright (c) 2005-2010, John Mettraux, jmettraux@gmail.com +# Copyright (c) 2005-2011, John Mettraux, jmettraux@gmail.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -45,49 +45,49 @@ # class CompositeStorage include StorageBase - def initialize (default_storage, storages) + def initialize(default_storage, storages) @default_storage = default_storage @storages = storages prepare_base_methods end - def put (doc, opts={}) + def put(doc, opts={}) storage(doc['type']).put(doc, opts) end - def get (type, key) + def get(type, key) storage(type).get(type, key) end - def delete (doc) + def delete(doc) - storage(type).delete(doc) + storage(doc['type']).delete(doc) end - def get_many (type, key=nil, opts={}) + def get_many(type, key=nil, opts={}) storage(type).get_many(type, key, opts) end - def ids (type) + def ids(type) storage(type).ids(type) end def purge! TYPES.collect { |t| storage(t) }.uniq.each { |s| s.purge! } end - def purge_type! (type) + def purge_type!(type) storage(type).purge_type!(type) end #def add_type (type) @@ -123,10 +123,10 @@ storage(type).send(method, *args) end end end - def storage (type) + def storage(type) @storages[type] || @default_storage end end end