Class: FlexiModel::ArModels::Record

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/flexi_model/ar_models/record.rb

Instance Method Summary collapse

Instance Method Details

#titleObject



23
24
25
26
27
28
# File 'lib/flexi_model/ar_models/record.rb', line 23

def title
  _value = value_of(:name) || value_of(:title)
  return _value.value if _value.present?

  self.collection.singular_label
end

#value_of(field_name) ⇒ Object



18
19
20
21
# File 'lib/flexi_model/ar_models/record.rb', line 18

def value_of(field_name)
  values.select{|v| v.field.present? }.
      select{|v| v.field.name.downcase == field_name.to_s.downcase}.first
end