module Attrio::Helpers
Public Instance Methods
symbolize_hash_keys(hash)
click to toggle source
note that returning hash without symbolizing anything does not cause this to fail
# File lib/attrio/helpers.rb, line 17 def symbolize_hash_keys(hash) hash.inject({}) do |new_hash, (key, value)| new_hash[(key.to_sym rescue key) || key] = value new_hash end hash end
to_a(object)
click to toggle source
# File lib/attrio/helpers.rb, line 5 def to_a(object) if object.nil? [] elsif object.respond_to?(:to_ary) object.to_ary || [object] else [object] end end