Module: Bhf::ActiveRecord::Base

Extended by:
ActiveSupport::Concern
Defined in:
lib/bhf/active_record/base.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#to_bhf_sObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/bhf/active_record/base.rb', line 6

def to_bhf_s
  return title if self.respond_to? :title
  return name if self.respond_to? :name
  return headline if self.respond_to? :headline

  if self.respond_to?(:attributes)
    return title if attributes['title']
    return name if attributes['name']
    klass_name = if self.class.respond_to?(:model_name)
      self.class.model_name.human
    else
      self.class.to_s.humanize
    end
    return "#{klass_name} ID: #{send(self.class.primary_key)}" if attributes[self.class.primary_key]
  end

  self.to_s.humanize
end