Class: Lolita::Adapter::CommonHelper::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/lolita/adapter/common_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter, orm_record) ⇒ Record

Returns a new instance of Record.



6
7
8
9
# File 'lib/lolita/adapter/common_helper.rb', line 6

def initialize(adapter, orm_record)
  @adapter = adapter
  @record = orm_record
end

Instance Method Details

#titleObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/lolita/adapter/common_helper.rb', line 11

def title
  if @record.respond_to?(:title)
    @record.title
  elsif @record.respond_to?(:name)
    @record.name
  elsif content_field = @adapter.fields.detect{|f| f.type.to_s=="string"}
    @record.send(content_field.name)
  else
    "#{@record.class.lolita_model_name.human} #{@record.id}"
  end
end