Sha256: 65c0fb93846d63a17c1ef13e11a6e1bbe5a1a2d9efb066e673b1e2d20094c789
Contents?: true
Size: 854 Bytes
Versions: 7
Compression:
Stored size: 854 Bytes
Contents
require 'active_type/mutation_after_cast_error' module ActiveType module Util # This object is used as a substitute for a record's @attributes. # Reading from the original @attributes is still allowed, to enable # `#inspect` and similar functions. # But the @attributes can no longer be mutated and will raise instead. class UnmutableAttributes attr_reader :original_attributes def initialize(attributes) @original_attributes = attributes end def fetch_value(key) original_attributes.fetch_value(key) end def key?(key) original_attributes.key?(key) end def method_missing(*args) raise MutationAfterCastError, 'Changing a record that has been used to create an ActiveType::Record could have unexpected side effects!' end end end end
Version data entries
7 entries across 7 versions & 1 rubygems