Class: RedSnow::Object
- Inherits:
-
Object
- Object
- RedSnow::Object
- Defined in:
- lib/redsnow/object.rb
Overview
Class from MatterCompiler as ascendant
Instance Method Summary collapse
-
#blank? ⇒ Boolean
Returns true if object is nil or empty, false otherwise.
-
#deep_symbolize_keys ⇒ Object
Symbolizes keys of a hash.
Instance Method Details
#blank? ⇒ Boolean
Returns true if object is nil or empty, false otherwise
13 14 15 |
# File 'lib/redsnow/object.rb', line 13 def blank? respond_to?(:empty?) ? empty? : !self end |
#deep_symbolize_keys ⇒ Object
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 |