Sha256: 5355b80978e73f1401c3ec472b78c4a97c4ee0db48aea247276006b5d3d763e3
Contents?: true
Size: 784 Bytes
Versions: 5
Compression:
Stored size: 784 Bytes
Contents
module Vedeu class Storage def initialize @map = {} end def create(record) map_for(record)[record.name] = record end def delete(record) map_for(record).delete(record.name) end def reset(entity) all(entity).map { |record| delete(record) } end def all(entity) map_for_class(entity).values end def query(entity, attribute, value) return false if value.nil? || value.empty? map_for_class(entity).select do |_, result| return result if result.send(attribute) == value end false end private attr_reader :map def map_for_class(entity) map[entity.to_s.to_sym] ||= {} end def map_for(record) map_for_class(record.class) end end end
Version data entries
5 entries across 5 versions & 1 rubygems