lib/vedeu/repository/storage.rb in vedeu-0.0.18 vs lib/vedeu/repository/storage.rb in vedeu-0.0.19
- old
+ new
@@ -1,14 +1,14 @@
module Vedeu
class Storage
def initialize
@counter = 0
- @map = {}
+ @map = {}
end
def create(record)
- @counter = @counter + 1
+ @counter += 1
record.id ||= @counter
map_for(record)[record.id] = record
end
def delete(record)
@@ -26,10 +26,10 @@
def all(klass)
map_for_class(klass).values
end
def query(klass, attribute, value)
- map_for_class(klass).select do |id, result|
+ map_for_class(klass).select do |_, result|
return result if result.send(attribute) == value
end
nil
end