Class: Lolita::Adapter::CommonHelper::Record
- Defined in:
- lib/lolita/adapter/common_helper.rb
Instance Method Summary collapse
-
#initialize(adapter, orm_record) ⇒ Record
constructor
A new instance of Record.
- #title ⇒ Object
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
#title ⇒ Object
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 |