Class: RedSnow::Object

Inherits:
Object
  • Object
show all
Defined in:
lib/redsnow/object.rb

Overview

Class from MatterCompiler as ascendant

Instance Method Summary collapse

Instance Method Details

#blank?Boolean

Returns true if object is nil or empty, false otherwise

Returns:

  • (Boolean)


13
14
15
# File 'lib/redsnow/object.rb', line 13

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

#deep_symbolize_keysObject

Symbolizes keys of a hash



6
7
8
9
10
# File 'lib/redsnow/object.rb', line 6

def deep_symbolize_keys
  return each_with_object({}) { |memo, (k, v)| memo[k.to_sym] = v.deep_symbolize_keys } if self.is_a?(Hash)
  return each_with_object([]) { |memo, v| memo << v.deep_symbolize_keys } if self.is_a?(Array)
  self
end