Sha256: 6e6812716689b1216bcd472f6775a2c8e15aa6afcd369d8efe354d633672891d
Contents?: true
Size: 740 Bytes
Versions: 1
Compression:
Stored size: 740 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) storage.select do |name, result| return result if name == value end unless value.nil? || value.empty? fail EntityNotFound, "Interface could not be found." end def reset @storage = {} end private def storage @storage ||= {} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.1.2 | lib/vedeu/support/persistence.rb |