class ActiveType::Util::UnmutableAttributes

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.

Attributes

original_attributes[R]

Public Class Methods

new(attributes) click to toggle source
# File lib/active_type/util/unmutable_attributes.rb, line 14
def initialize(attributes)
  @original_attributes = attributes
end

Public Instance Methods

[](key) click to toggle source
# File lib/active_type/util/unmutable_attributes.rb, line 22
def [](key)
  original_attributes[key]
end
fetch_value(key) click to toggle source
# File lib/active_type/util/unmutable_attributes.rb, line 18
def fetch_value(key)
  original_attributes.fetch_value(key)
end
key?(key) click to toggle source
# File lib/active_type/util/unmutable_attributes.rb, line 26
def key?(key)
  original_attributes.key?(key)
end
method_missing(*args) click to toggle source
# File lib/active_type/util/unmutable_attributes.rb, line 30
def method_missing(*args)
  raise MutationAfterCastError, 'Changing a record that has been used to create an ActiveType::Record could have unexpected side effects!'
end