lib/toy/querying.rb in toystore-0.6.6 vs lib/toy/querying.rb in toystore-0.7.0

- old
+ new

@@ -2,28 +2,13 @@ module Querying extend ActiveSupport::Concern module ClassMethods def get(id) - key = store_key(id) - - if has_cache? - value = cache.read(key) - log_operation('RTG', self, cache, key, value) - end - - if value.nil? - value = store.read(key) - log_operation('GET', self, store, key, value) - - if has_cache? - cache.write(key, value) - log_operation('RTS', self, cache, key, value) - end - end - - load(key, value) + value = store.read(id) + log_operation(:get, self, store, id, value) + load(id, value) end def get!(id) get(id) || raise(Toy::NotFound.new(id)) end @@ -39,18 +24,17 @@ def get_or_create(id) get(id) || create(:id => id) end def key?(id) - key = store_key(id) - value = store.key?(key) - log_operation('KEY', self, store, key, value) + value = store.key?(id) + log_operation(:key, self, store, id, value) value end alias :has_key? :key? - def load(key, attrs) - attrs && allocate.initialize_from_database(attrs.update('id' => key)) + def load(id, attrs) + attrs && allocate.initialize_from_database(attrs.update('id' => id)) end end end end \ No newline at end of file