Sha256: 48afabc29b242d5fcdb75d1b83c4fcee94f92b1ba6abcb7367cbdc2c96dc937d
Contents?: true
Size: 910 Bytes
Versions: 1
Compression:
Stored size: 910 Bytes
Contents
require "forwardable" module SequelMapper class AbstractRecord extend Forwardable def initialize(namespace, identity, raw_data = {}) @namespace = namespace @identity = identity @raw_data = raw_data end attr_reader :namespace, :identity attr_reader :raw_data private :raw_data def_delegators :to_h, :fetch def if_upsert(&block) self end def if_delete(&block) self end def merge(more_data) new_with_raw_data(raw_data.merge(more_data)) end def to_h raw_data.merge(identity) end def ==(other) self.class === other && [operation, to_h] == [other.operation, other.to_h] end protected def operation raise NotImplementedError end private def new_with_raw_data(new_raw_data) self.class.new(namespace, identity, new_raw_data) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sequel_mapper-0.0.3 | lib/sequel_mapper/abstract_record.rb |