Module: MR::Model::InstanceMethods
- Defined in:
- lib/mr/model.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
- #initialize(*args) ⇒ Object
- #inspect ⇒ Object
Instance Method Details
#==(other) ⇒ Object
43 44 45 |
# File 'lib/mr/model.rb', line 43 def ==(other) other.kind_of?(self.class) ? self.record == other.record : super end |
#eql?(other) ⇒ Boolean
47 48 49 |
# File 'lib/mr/model.rb', line 47 def eql?(other) other.kind_of?(self.class) ? self.record.eql?(other.record) : super end |
#hash ⇒ Object
51 52 53 |
# File 'lib/mr/model.rb', line 51 def hash record.hash end |
#initialize(*args) ⇒ Object
35 36 37 38 39 40 41 |
# 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 |
#inspect ⇒ Object
55 56 57 58 59 60 61 |
# 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 |