Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/fidius-common/json_symbol_addon.rb

Overview

Part of the JSON Symbol Addon.

Instance Method Summary collapse

Instance Method Details

#symbolize_keys_if_neededObject

[1,“:aa”,:asa].symbolize_keys_if_needed

=> [1, :aa, :asa]


84
85
86
87
88
89
90
91
# File 'lib/fidius-common/json_symbol_addon.rb', line 84

def symbolize_keys_if_needed
  self.each_with_index do |e,i|
    e.symbolize_keys_if_needed if e.respond_to?("symbolize_keys_if_needed")
    if self[i].to_s[0] == ":"
      self[i] = e[1..-1].to_sym
    end
  end
end