Module: MR::FakeRecord::InstanceMethods

Defined in:
lib/mr/fake_record.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



37
38
39
# File 'lib/mr/fake_record.rb', line 37

def ==(other)
  other.kind_of?(self.class) ? self.id == other.id : super
end

#hashObject



42
43
44
# File 'lib/mr/fake_record.rb', line 42

def hash
  self.id.hash
end

#initialize(attrs = nil) ⇒ Object



33
34
35
# File 'lib/mr/fake_record.rb', line 33

def initialize(attrs = nil)
  self.attributes = attrs || {}
end

#inspectObject



46
47
48
49
50
51
52
# File 'lib/mr/fake_record.rb', line 46

def inspect
  object_hex = (self.object_id << 1).to_s(16)
  attributes_inspect = self.class.attributes.map do |attribute|
    "@#{attribute.name}=#{attribute.read(self).inspect}"
  end.sort.join(" ")
  "#<#{self.class}:0x#{object_hex} #{attributes_inspect}>"
end