Sha256: 63dc10c998e281bb1f38b54a10783c2bae390128b6c3ad07508d848abed150e9
Contents?: true
Size: 586 Bytes
Versions: 10
Compression:
Stored size: 586 Bytes
Contents
module BestInPlace module Utils extend self def build_best_in_place_id(object, field) if object.is_a?(Symbol) || object.is_a?(String) return "best_in_place_#{object}_#{field}" end id = "best_in_place_#{object_to_key(object)}" id << "_#{object.id}" if object.class.ancestors.include?(ActiveModel::Serializers::JSON) id << "_#{field}" id end def object_to_key(object) return object.class.to_s.underscore unless object.class.respond_to?(:model_name) ActiveModel::Naming.param_key(object.class) end end end
Version data entries
10 entries across 10 versions & 2 rubygems