lib/toy/querying.rb in toystore-0.6.1 vs lib/toy/querying.rb in toystore-0.6.2
- old
+ new
@@ -6,24 +6,24 @@
def get(id)
key = store_key(id)
if has_cache?
value = cache.read(key)
- log_operation('RTG', cache, key, value)
+ log_operation('RTG', self, cache, key, value)
end
if value.nil?
value = store.read(key)
- log_operation('GET', store, key, value)
+ log_operation('GET', self, store, key, value)
if has_cache?
cache.write(key, value)
- log_operation('RTS', cache, key, value)
+ log_operation('RTS', self, cache, key, value)
end
end
- load(value)
+ load(key, value)
end
def get!(id)
get(id) || raise(Toy::NotFound.new(id))
end
@@ -41,16 +41,17 @@
end
def key?(id)
key = store_key(id)
value = store.key?(key)
- log_operation('KEY', store, key, value)
+ log_operation('KEY', self, store, key, value)
value
end
alias :has_key? :key?
- def load(attrs)
+ def load(key, attrs)
return nil if attrs.nil?
+ attrs['id'] = key
allocate.initialize_from_database(attrs)
end
end
end
end
\ No newline at end of file