Class: Leva::DatasetRecord

Inherits:
ApplicationRecord show all
Defined in:
app/models/leva/dataset_record.rb

Instance Method Summary collapse

Instance Method Details

#display_nameString

Returns A string representation of the record for display purposes.

Returns:

  • (String)

    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_attributesHash

Returns A hash of attributes to be displayed in the dataset records index.

Returns:

  • (Hash)

    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_attributesHash

Returns A hash of attributes to be displayed in the dataset record show view.

Returns:

  • (Hash)

    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