Class: BestInPlaceish::Utils

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

Class Method Summary collapse

Class Method Details

.build_best_in_placeish_id(object, field) ⇒ Object



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

def self.build_best_in_placeish_id(object, field)
  if object.is_a?(Symbol) || object.is_a?(String)
    return "best_in_placeish_#{object}_#{field}"
  end

  id = "best_in_placeish_#{object.class.to_s.demodulize.underscore}"
  id << "_#{object.id}" if object.class.ancestors.include?(ActiveRecord::Base)
  id << "_#{field}"
  id
end