Sha256: 4ccdcd88a0d884b1d5fc95bc2153f39f8dd5bb3be43f5c56083c293f3b137b01

Contents?: true

Size: 752 Bytes

Versions: 48

Compression:

Stored size: 752 Bytes

Contents

# Thanks ruby on rails!
#
# These are all blatent, unapologetic rip offs of RoR extensions, and they
# behave in exactly the same way.

class Object

  def blank?
    respond_to?(:empty?) ? empty? : !self
  end

  def present?
    !blank?
  end

  # okay, this is strange, but `rake spec` fails if I define the method as `in?`
  # but passes if I alias it, as I do below.  weird, but I don't want to fight
  # it.
  def __in_workaround(args, *other_args)
    if other_args.length > 0
      raise "The varargs form of `Object#in?` has been removed.  Use an array instead."
    end
    args.include?(self)
  rescue NoMethodError
    raise ArgumentError.new("The parameter passed to #in? must respond to #include?")
  end
  alias in? __in_workaround

end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
sugarcube-1.0.2 lib/sugarcube-legacy/activesupport.rb
sugarcube-1.0.1 lib/sugarcube-legacy/activesupport.rb
sugarcube-1.0.0 lib/sugarcube-legacy/activesupport.rb
sugarcube-0.20.25 lib/sugarcube/activesupport.rb
sugarcube-0.20.24 lib/sugarcube/activesupport.rb
sugarcube-0.20.23 lib/sugarcube/activesupport.rb
sugarcube-0.20.22 lib/sugarcube/activesupport.rb
sugarcube-0.20.21 lib/sugarcube/activesupport.rb