Sha256: c8dbd2efa496b1d947c898bf664ebc1b677be10ae6c3596b5903e61ac408ea02

Contents?: true

Size: 770 Bytes

Versions: 11

Compression:

Stored size: 770 Bytes

Contents

class Object
  def try(*a, &b)
    if a.empty? && block_given?
      yield self
    else
      public_send(*a, &b) if respond_to?(a.first)
    end
  end
end

class String
  def blank?
    strip == ''
  end

  def present?
    !blank?
  end
end

class Array
  def blank?
    empty?
  end
  def empty?
    self == []
  end

  def present?
    !empty?
  end
end

class Fixnum
  def present?
    true
  end

  def blank?
    false
  end
end

class NilClass
  def present?
    false
  end

  def blank?
    true
  end

  def empty?
    true
  end
end

class Hash
  def present?
    !blank?
  end

  def blank?
    empty?
  end

  def symbolize_keys
    self.inject({}){|rslt, (k, v)| rslt.merge(k.to_sym => v) }
  end

  def reverse_merge(hash)
    hash.merge self
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sentimeta-0.1.22 lib/sentimeta/support.rb
sentimeta-0.1.21 lib/sentimeta/support.rb
sentimeta-0.1.20 lib/sentimeta/support.rb
sentimeta-0.1.10 lib/sentimeta/support.rb
sentimeta-0.1.9 lib/sentimeta/support.rb
sentimeta-0.1.8 lib/sentimeta/support.rb
sentimeta-0.1.7 lib/sentimeta/support.rb
sentimeta-0.1.6 lib/sentimeta/support.rb
sentimeta-0.1.5 lib/sentimeta/support.rb
sentimeta-0.1.4 lib/sentimeta/support.rb
sentimeta-0.1.3 lib/sentimeta/support.rb