Skip to content

Undefined SerializationTypeMismatch error #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/gigo/active_record/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def load(yaml)
Encoding.default_internal = GIGO.encoding
value = YAML.load(GIGO.load(yaml))
unless value.is_a?(klass)
raise SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{hash.class}."
raise ::ActiveRecord::SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{value.class}: #{value.inspect}"
end
value
ensure
Expand All @@ -64,7 +64,7 @@ def load(yaml)
def dump(value)
return klass.new.to_yaml if value.nil?
unless value.is_a?(klass)
raise SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{value.class}."
raise ::ActiveRecord::SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{value.class}: #{value.inspect}"
end
value.to_yaml
end
Expand All @@ -74,4 +74,3 @@ def dump(value)
end

ActiveRecord::Base.extend GIGO::ActiveRecord::Base