aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/object/misc.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/misc.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/object/misc.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/misc.rb b/activesupport/lib/active_support/core_ext/object/misc.rb
new file mode 100644
index 0000000000..f599eee6f0
--- /dev/null
+++ b/activesupport/lib/active_support/core_ext/object/misc.rb
@@ -0,0 +1,16 @@
+class Object #:nodoc:
+ def with_options(options)
+ yield ActiveSupport::OptionMerger.new(self, options)
+ end
+
+ def to_json
+ ActiveSupport::JSON.encode(self)
+ end
+
+ def suppress(*exception_classes)
+ begin yield
+ rescue Exception => e
+ raise unless exception_classes.any? { |cls| e.kind_of?(cls) }
+ end
+ end
+end \ No newline at end of file