module MR::Model::InstanceMethods

Public Class Methods

new(*args) click to toggle source
# File lib/mr/model.rb, line 35
def initialize(*args)
  field_values = args.pop if args.last.kind_of?(Hash)
  set_record(args.first || self.record_class.new)
  (field_values || {}).each do |name, value|
    self.send("#{name}=", value)
  end
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/mr/model.rb, line 43
def ==(other)
  other.kind_of?(self.class) ? self.record == other.record : super
end
eql?(other) click to toggle source
Calls superclass method
# File lib/mr/model.rb, line 47
def eql?(other)
  other.kind_of?(self.class) ? self.record.eql?(other.record) : super
end
hash() click to toggle source
# File lib/mr/model.rb, line 51
def hash
  record.hash
end
inspect() click to toggle source
# File lib/mr/model.rb, line 55
def inspect
  object_hex = (self.object_id << 1).to_s(16)
  fields_inspect = self.class.fields.map do |field|
    "@#{field.name}=#{field.read(record).inspect}"
  end.sort.join(" ")
  "#<#{self.class}:0x#{object_hex} #{fields_inspect}>"
end