Sha256: 8252f359425c78d848cd51c21a99d6a0c4dd27570e0a7399e929677ec99e0eb2
Contents?: true
Size: 602 Bytes
Versions: 3
Compression:
Stored size: 602 Bytes
Contents
# frozen_string_literal: true class Sample # This is a stub model for testing. cattr_accessor :objects self.objects = {} def self.create(_params = {}) obj = Sample.new obj.save obj end def save @pid ||= "sample:#{(rand * 1000).to_i}" self.class.objects[@pid] = self end def update_attributes(attributes) attributes.each do |k, v| instance_variable_set "@#{k}".to_sym, v self.class.send :attr_accessor, k end end def self.find(pid) objects[pid] end attr_reader :pid def destroy self.class.objects.delete(@pid) end end
Version data entries
3 entries across 3 versions & 1 rubygems