Sha256: dda36459eda6625a3506fb51281fc22231eea17f862487819cc5286f52546686

Contents?: true

Size: 567 Bytes

Versions: 152

Compression:

Stored size: 567 Bytes

Contents

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module Array #:nodoc:
      module Wrapper
        # Wraps the object in an Array unless it's an Array.  Converts the
        # object to an Array using #to_ary if it implements that.
        def wrap(object)
          case object
          when nil
            []
          when self
            object
          else
            if object.respond_to?(:to_ary)
              object.to_ary
            else
              [object]
            end
          end
        end
      end
    end
  end
end

Version data entries

152 entries across 121 versions & 15 rubygems

Version Path
activesupport-2.3.12 lib/active_support/core_ext/array/wrapper.rb
radiant-1.0.0.rc2 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiant-1.0.0.rc1 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
abiquo-etk-0.5.3 vendor/activesupport-2.3.8/lib/active_support/core_ext/array/wrapper.rb
abiquo-etk-0.4.42 vendor/activesupport-2.3.8/lib/active_support/core_ext/array/wrapper.rb
webroar-0.5.0 src/admin_panel/vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
activesupport-2.3.11 lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.2.4 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.2.2 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.2.1 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.2 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.9 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.8 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.7 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.6 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.5 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.4 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.3 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.2 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb
radiantcms-couchrest_model-0.1.1 vendor/rails/activesupport/lib/active_support/core_ext/array/wrapper.rb