Sha256: fb5696acf06f57aaf42b5d3cd892c4e50fa0e871f0a58cade377bf66a8cb1812

Contents?: true

Size: 633 Bytes

Versions: 15

Compression:

Stored size: 633 Bytes

Contents

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 foo
  #     returning [] do |values|
  #       values << 'bar'
  #       values << 'baz'
  #     end
  #   end
  #
  #   foo # => ['bar', 'baz']
  #
  def returning(value)
    yield(value)
    value
  end

  def with_options(options)
    yield ActiveSupport::OptionMerger.new(self, options)
  end
  
  def to_json
    ActiveSupport::JSON.encode(self)
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
activesupport-1.3.1 lib/active_support/core_ext/object/misc.rb
activesupport-1.4.2 lib/active_support/core_ext/object/misc.rb
activesupport-1.4.0 lib/active_support/core_ext/object/misc.rb
activesupport-1.4.4 lib/active_support/core_ext/object/misc.rb
activesupport-1.4.3 lib/active_support/core_ext/object/misc.rb
activesupport-1.4.1 lib/active_support/core_ext/object/misc.rb
activesupport-1.3.0 lib/active_support/core_ext/object/misc.rb
monetra-ruby-0.0.6 lib/monetra/active_support/core_ext/object/misc.rb
radiant-0.6.0 vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb
radiant-0.6.1 vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb
radiant-0.6.3 vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb
radiant-0.6.2 vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb
radiant-0.6.4 vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb
rq-3.3.0 rails/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb
rq-3.4.0 rails/vendor/rails/activesupport/lib/active_support/core_ext/object/misc.rb