Sha256: 6d1442c6a31f815940fe95e7dd1bf6474b3b1870da5a58f1135a2b571fd86f39

Contents?: true

Size: 549 Bytes

Versions: 13

Compression:

Stored size: 549 Bytes

Contents

# Essential extensions to base object class
module RedSnow
  # Class from MatterCompiler as ascendant
  class Object

    # Symbolizes keys of a hash
    def deep_symbolize_keys
      return self.inject({}){|memo, (k,v)| memo[k.to_sym] = v.deep_symbolize_keys; memo} if self.is_a? Hash
      return self.inject([]){|memo, v | memo << v.deep_symbolize_keys; memo} if self.is_a? Array
      return self
    end

    # Returns true if object is nil or empty, false otherwise
    def blank?
      respond_to?(:empty?) ? empty? : !self
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
redsnow-0.3.2 lib/redsnow/object.rb
redsnow-0.3.1 lib/redsnow/object.rb
redsnow-0.3.0 lib/redsnow/object.rb
redsnow-0.2.1 lib/redsnow/object.rb
redsnow-0.2.0 lib/redsnow/object.rb
redsnow-0.1.6 lib/redsnow/object.rb
redsnow-0.1.5 lib/redsnow/object.rb
redsnow-0.1.4 lib/redsnow/object.rb
redsnow-0.1.3 lib/redsnow/object.rb
redsnow-0.1.2 lib/redsnow/object.rb
redsnow-0.1.1 lib/redsnow/object.rb
redsnow-0.1.0 lib/redsnow/object.rb
redsnow-0.0.8 lib/redsnow/object.rb