Sha256: 931ce526f2d15b915bccf9024ae4bf5eb47051fa48d7007351010c4bfcfa3282
Contents?: true
Size: 879 Bytes
Versions: 1
Compression:
Stored size: 879 Bytes
Contents
# -*- coding: utf-8 -*- =begin rdoc Please see README.rdoc =end class ActiveRecordMock @@find=[] def initialize(ops={}) @attributes=ops @@find << self end def read_attribute(k) @attributes[k] end def write_attribute(k,v) @attributes[k]=v end def self.find(id,ops={}) case id when nil raise ArgumentError.new when :all return @@find else @@find.each{|x| if x.read_attribute(:id)==id then return x end } return nil end end def self.find_by_id(id,ops={}) case id when nil nil else self.find(id,ops) end end def self.find=(records) @@find=records end def method_missing(m, *args, &block) if m=~/=$/ write_attribute(m.to_s.sub(/=$/,'').to_sym, *args) else if m=~/_before_type_cast$/ read_attribute($`.to_sym) else read_attribute(m) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sixarm_ruby_active_record_mock-1.4.6 | lib/sixarm_ruby_active_record_mock.rb |