diff --git a/config/initializers/00_extensions.rb b/config/initializers/00_extensions.rb index a534bc80f7..4f3bba67ea 100644 --- a/config/initializers/00_extensions.rb +++ b/config/initializers/00_extensions.rb @@ -41,3 +41,7 @@ class TrueClass class FalseClass include Extensions::BooleanExtension::False end + +class Object + include Extensions::ObjectExtension +end diff --git a/lib/extensions/object_extension.rb b/lib/extensions/object_extension.rb new file mode 100644 index 0000000000..72b0d11f72 --- /dev/null +++ b/lib/extensions/object_extension.rb @@ -0,0 +1,11 @@ +module Extensions + module ObjectExtension + def as_json(options = nil) + if respond_to?(:to_hash) + to_hash.as_json(options) + else + self.to_s + end + end + end +end