Sha256: 9631b7b58d59e60da6105d9f3ede2d9953ab1891db547eb5a74cbd5dabb79dda

Contents?: true

Size: 834 Bytes

Versions: 215

Compression:

Stored size: 834 Bytes

Contents

class Object
  # Returns true if this object is included in the argument(s). Argument must be
  # any object which responds to +#include?+ or optionally, multiple arguments can be passed in. Usage:
  #
  #   characters = ["Konata", "Kagami", "Tsukasa"]
  #   "Konata".in?(characters) # => true
  #   
  #   character = "Konata"
  #   character.in?("Konata", "Kagami", "Tsukasa") # => true
  #
  # This will throw an ArgumentError if a single argument is passed in and it doesn't respond
  # to +#include?+.
  def in?(*args)
    if args.length > 1
      args.include? self
    else
      another_object = args.first
      if another_object.respond_to? :include?
        another_object.include? self
      else
        raise ArgumentError.new("The single parameter passed to #in? must respond to #include?")
      end
    end
  end
end

Version data entries

215 entries across 171 versions & 24 rubygems

Version Path
active_mailer-0.0.3 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.12/lib/active_support/core_ext/object/inclusion.rb
activesupport-3.2.12 lib/active_support/core_ext/object/inclusion.rb
graphael-on-rails-0.5.1 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
graphael-on-rails-0.0.1 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
challah-0.9.1.beta.3 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
devise_sociable-0.1.0 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
backbone-queryparams-rails-0.0.1 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
railscast-assets-0.0.2 vendor/bundle/gems/backbone-forms-on-rails-0.10.0/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
railscast-assets-0.0.2 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
backbone-forms-on-rails-0.10.0 vendor/bundle/gems/backbone-forms-on-rails-0.10.0/vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
backbone-forms-on-rails-0.10.0 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
backbone-deep-rails-0.0.2 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
backbone-deep-rails-0.0.1 vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
challah-0.9.1.beta vendor/bundle/gems/activesupport-3.2.11/lib/active_support/core_ext/object/inclusion.rb
activesupport-3.2.11 lib/active_support/core_ext/object/inclusion.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.10/lib/active_support/core_ext/object/inclusion.rb
challah-0.9.0 vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/inclusion.rb
activesupport-3.2.10 lib/active_support/core_ext/object/inclusion.rb
classiccms-0.6.9 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/core_ext/object/inclusion.rb
jquery_regex-0.0.3 vendor/bundle/gems/jquery_regex-0.0.3/vendor/bundle/gems/jquery_regex-0.0.2/vendor/bundle/gems/activesupport-3.2.9/lib/active_support/core_ext/object/inclusion.rb