Module: ComponentSettingsConcern

Extended by:
ActiveSupport::Concern
Included in:
Course::Settings::Components, Instance::Settings::Components
Defined in:
app/models/concerns/component_settings_concern.rb

Instance Method Summary collapse

Instance Method Details

#disableable_component_collectionObject

This is used when generating checkboxes for each of the components


6
7
8
# File 'app/models/concerns/component_settings_concern.rb', line 6

def disableable_component_collection
  @settable.disableable_components.map { |c| [c.display_name, c.key.to_s] }.sort
end

#enabled_component_idsArray<String>

Returns the ids of enabled components that can be disabled

Returns:

  • (Array<String>)

    The array which stores the ids, ids here are the keys of components


13
14
15
16
17
18
# File 'app/models/concerns/component_settings_concern.rb', line 13

def enabled_component_ids
  @enabled_component_ids ||= begin
    components = @settable.user_enabled_components - @settable.undisableable_components
    components.map { |c| c.key.to_s }
  end
end

#enabled_component_ids=(ids) ⇒ Array<String>

Disable/Enable components

Parameters:

  • ids (Array<String>)

    the ids of all the enabled components

Returns:

  • (Array<String>)

    the ids of all the enabled components


24
25
26
# File 'app/models/concerns/component_settings_concern.rb', line 24

def enabled_component_ids=(ids)
  @settable.enabled_components_keys = ids
end