Module: Interest::Utils

Defined in:
lib/interest/utils.rb

Class Method Summary collapse

Class Method Details

.source_type_of(object, prefix = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/interest/utils.rb', line 17

def source_type_of(object, prefix = nil)
  case model_class_or_instance(object)
  when :instance
    object.class.model_name.to_s
  when :class
    object.model_name.to_s
  else
    source_type_from_letter_of(object, prefix)
  end
end

.symbolic_name_of(object) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/interest/utils.rb', line 9

def symbolic_name_of(object)
  if model_class_or_instance(object)
    ActiveModel::Naming.plural(object)
  else
    object.to_s.underscore.gsub("/", "_").pluralize
  end
end