Skip to content

Commit e935047

Browse files
authored
Undefined SerializationTypeMismatch error (#5)
* Fix SerializationTypeMismatch error message * Include a value in the error message for debuging ease * Use ActiveRecord::SerializationTypeMismatch instead of custom GigoCoder::SerializationTypeMismatch * Bump version to 2.0.2
1 parent 87c03b4 commit e935047

File tree

6 files changed

+7
-8
lines changed

6 files changed

+7
-8
lines changed

gemfiles/activerecord42.gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
gigo-activerecord (2.0.1)
4+
gigo-activerecord (2.0.2)
55
activerecord (>= 4.2.0)
66
gigo
77

gemfiles/activerecord50.gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
gigo-activerecord (2.0.1)
4+
gigo-activerecord (2.0.2)
55
activerecord (>= 4.2.0)
66
gigo
77

gemfiles/activerecord51.gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
gigo-activerecord (2.0.1)
4+
gigo-activerecord (2.0.2)
55
activerecord (>= 4.2.0)
66
gigo
77

gemfiles/activerecord52.gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ..
33
specs:
4-
gigo-activerecord (2.0.1)
4+
gigo-activerecord (2.0.2)
55
activerecord (>= 4.2.0)
66
gigo
77

lib/gigo/active_record/base.rb

+2-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def load(yaml)
5454
Encoding.default_internal = GIGO.encoding
5555
value = YAML.load(GIGO.load(yaml))
5656
unless value.is_a?(klass)
57-
raise SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{hash.class}."
57+
raise ::ActiveRecord::SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{value.class}: #{value.inspect}"
5858
end
5959
value
6060
ensure
@@ -64,7 +64,7 @@ def load(yaml)
6464
def dump(value)
6565
return klass.new.to_yaml if value.nil?
6666
unless value.is_a?(klass)
67-
raise SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{value.class}."
67+
raise ::ActiveRecord::SerializationTypeMismatch, "Attribute was supposed to be a #{klass.to_s}, but was a #{value.class}: #{value.inspect}"
6868
end
6969
value.to_yaml
7070
end
@@ -74,4 +74,3 @@ def dump(value)
7474
end
7575

7676
ActiveRecord::Base.extend GIGO::ActiveRecord::Base
77-

lib/gigo/active_record/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module GIGO
22
module ActiveRecord
3-
VERSION = "2.0.1"
3+
VERSION = "2.0.2"
44
end
55
end

0 commit comments

Comments
 (0)