Module: BestInPlace::Utils
Instance Method Summary collapse
Instance Method Details
#build_best_in_place_id(object, field) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/best_in_place/utils.rb', line 5 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 |
#object_to_key(object) ⇒ Object
16 17 18 19 |
# File 'lib/best_in_place/utils.rb', line 16 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 |