Class: Hyrax::DefaultAdministrativeSet

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/hyrax/default_administrative_set.rb

Overview

This class stores the id of the default ‘Hyrax::AdministrativeSet`. This is used to populate a cache of the default admin set in Hyrax::Configuration.

See Also:

  • Configuration.default_admin_set
  • Configuration.default_admin_set_id
  • Configuration.reset_default_admin_set

Class Method Summary collapse

Class Method Details

.save_supported?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/hyrax/default_administrative_set.rb', line 28

def save_supported?
  ActiveRecord::Base.connection.table_exists? table_name
end

.update(default_admin_set_id:) ⇒ Object

Set the default admin set id in the first record.

Parameters:

  • default_admin_set_id (String | Valkyrie::ID)

    id of the new default admin set



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/hyrax/default_administrative_set.rb', line 15

def update(default_admin_set_id:)
  validate_id(default_admin_set_id)
  Hyrax.config.reset_default_admin_set

  # saving default_admin_set_id for the first time
  return new(default_admin_set_id: default_admin_set_id.to_s).save if count.zero?

  # replacing previously saved default_admin_set_id
  existing = first
  existing.default_admin_set_id = default_admin_set_id.to_s
  existing.save
end