Class: BestInPlaceMongoid::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/best_in_place_mongoid/utils.rb

Class Method Summary collapse

Class Method Details

.build_best_in_place_id(object, field) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/best_in_place_mongoid/utils.rb', line 4

def self.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.class.to_s.demodulize.underscore}"
  id << "_#{object.id}" if object.class.ancestors.include?(Mongoid::Document)
  id << "_#{field}"
  id
end