Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-641

BSON::OrderedHash should allow options extraction using Array#extract_options!

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 1.9.1
    • Affects Version/s: 1.8.6
    • Component/s: BSON
    • Environment:
      Ubuntu 12.04, Ruby 1.9.3-p327, activesupport 3.2.13, bson 1.8.6

      There's a commonly used approach to extract options from method arguments using Array#extract_options!

      Example:

      Unable to find source-code formatter for language: ruby. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      require 'active_support'
      
      def foo(*args)
        args.extract_options!
      end
      
      foo(1, 1, { :some => 'hash' })  # => { :some => 'hash' } 
      

      However when using `bson` gem inside a project the example above returns {}.

      ActiveSupport requires BSON::OrderedHash to implement method #extractable_options? to support options extraction. See https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/array/extract_options.rb#L7

      Expected result: It should still be possible to use Array#extract_options! if a gem has dependency on `bson`

            Assignee:
            tyler@10gen.com Tyler Brock
            Reporter:
            roody Konstantin Rudy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: