Sha256: 35a5801c105485876c223277eef241f817b85e150ae7e6e5865b78b60bba3f7b
Contents?: true
Size: 756 Bytes
Versions: 5
Compression:
Stored size: 756 Bytes
Contents
require 'vedeu/models/interface' module Vedeu EntityNotFound = Class.new(StandardError) module Persistence extend self def update(name, attributes = {}) interface = query(name) interface.attributes = attributes interface rescue EntityNotFound create(attributes) end def create(attributes) storage.store(attributes[:name], Interface.new(attributes)) end def query(value) return false if value.nil? || value.empty? storage.select do |name, result| return result if name == value end fail EntityNotFound, "Interface could not be found." end def reset @storage = {} end private def storage @storage ||= {} end end end
Version data entries
5 entries across 5 versions & 1 rubygems