Class: Leva::DatasetRecord
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Leva::DatasetRecord
- Defined in:
- app/models/leva/dataset_record.rb
Instance Method Summary collapse
-
#display_name ⇒ String
A string representation of the record for display purposes.
-
#index_attributes ⇒ Hash
A hash of attributes to be displayed in the dataset records index.
-
#show_attributes ⇒ Hash
A hash of attributes to be displayed in the dataset record show view.
Instance Method Details
#display_name ⇒ String
Returns A string representation of the record for display purposes.
55 56 57 58 59 60 61 62 63 |
# File 'app/models/leva/dataset_record.rb', line 55 def display_name if recordable.respond_to?(:name) recordable.name elsif recordable.respond_to?(:title) recordable.title else "#{recordable_type} ##{recordable_id}" end end |
#index_attributes ⇒ Hash
Returns A hash of attributes to be displayed in the dataset records index.
33 34 35 36 37 38 39 40 41 |
# File 'app/models/leva/dataset_record.rb', line 33 def index_attributes if recordable.respond_to?(:index_attributes) recordable.index_attributes elsif recordable.respond_to?(:name) { name: recordable.name } else { to_s: recordable.to_s } end end |
#show_attributes ⇒ Hash
Returns A hash of attributes to be displayed in the dataset record show view.
44 45 46 47 48 49 50 51 52 |
# File 'app/models/leva/dataset_record.rb', line 44 def show_attributes if recordable.respond_to?(:show_attributes) recordable.show_attributes elsif recordable.respond_to?(:dataset_attributes) recordable.dataset_attributes else { to_s: recordable.to_s } end end |