Method: ActivityNotification.cast_to_indifferent_hash
- Defined in:
- lib/activity_notification/common.rb
.cast_to_indifferent_hash(hash = {}) ⇒ HashWithIndifferentAccess
Casts to indifferent hash
53 54 55 56 57 58 59 |
# File 'lib/activity_notification/common.rb', line 53 def self.cast_to_indifferent_hash(hash = {}) # This is the typical (not-ActionView::TestCase) code path. hash = hash.to_unsafe_h if hash.respond_to?(:to_unsafe_h) # In Rails 5 to_unsafe_h returns a HashWithIndifferentAccess, in Rails 4 it returns Hash hash = hash.with_indifferent_access if hash.instance_of? Hash hash end |