Sha256: fa79b916a39eb6583e01d9c216be37323a39f8812ca4d9bbc1b91f8565f0df38

Contents?: true

Size: 580 Bytes

Versions: 1

Compression:

Stored size: 580 Bytes

Contents

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_s}".to_sym, v
      self.class.send :attr_accessor, k
    end
  end

  def self.find(pid)
    objects[pid]
  end

  def pid
    @pid
  end

  def destroy
    self.class.objects.delete(@pid)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hydra-ezid-0.0.1 spec/support/app/models/sample.rb