diff options
Diffstat (limited to 'activesupport/lib/active_support/core_ext/object/misc.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/object/misc.rb | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/misc.rb b/activesupport/lib/active_support/core_ext/object/misc.rb index f599eee6f0..52c3773eea 100644 --- a/activesupport/lib/active_support/core_ext/object/misc.rb +++ b/activesupport/lib/active_support/core_ext/object/misc.rb @@ -1,4 +1,20 @@ class Object #:nodoc: + # A Ruby-ized realization of the K combinator, courtesy of Mikael Brockman. + # + # def foo + # returning values = [] do + # values << 'bar' + # values << 'baz' + # end + # end + # + # foo # => ['bar', 'baz'] + # + def returning(value) + yield + value + end + def with_options(options) yield ActiveSupport::OptionMerger.new(self, options) end @@ -6,11 +22,4 @@ class Object #:nodoc: 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 |