Class: Course::Settings::LeaderboardComponent

Inherits:
Component
  • Object
show all
Includes:
ActiveModel::Conversion
Defined in:
app/models/course/settings/leaderboard_component.rb

Instance Method Summary collapse

Instance Method Details

#display_user_countInteger

Returns the number of users to be displayed on the leaderboard

Returns:

  • (Integer)

    The number of users to be displayed


25
26
27
# File 'app/models/course/settings/leaderboard_component.rb', line 25

def display_user_count
  settings.display_user_count || 30
end

#display_user_count=(count) ⇒ Object

Set the number of users to be displayed on the leaderboard

Parameters:

  • count (Integer)

    The number of users to be displayed


32
33
34
# File 'app/models/course/settings/leaderboard_component.rb', line 32

def display_user_count=(count)
  settings.display_user_count = count
end

#enable_group_leaderboardBoolean

Returns whether group leaderboard is enabled (disabled by default).

Returns:

  • (Boolean)

    Setting on whether group leaderboard is enabled.


39
40
41
# File 'app/models/course/settings/leaderboard_component.rb', line 39

def enable_group_leaderboard
  group_leaderboard_settings.enabled == true
end

#enable_group_leaderboard=(option) ⇒ Object

Enable or disable the option to display group leaderboard

Parameters:

  • option (Boolean|Integer|String)

    Setting on whether group leaderboard is enabled. By default, simple_form provides ‘0’ and ‘1’ for boolean fields. This method will handle this conversion to Boolean.


48
49
50
51
# File 'app/models/course/settings/leaderboard_component.rb', line 48

def enable_group_leaderboard=(option)
  option = ActiveRecord::Type::Boolean.new.cast(option)
  group_leaderboard_settings.enabled = option
end

#group_leaderboard_titleString

Returns the title of group leaderboard

Returns:

  • (String)

    The custom or default title of group leaderboard component


56
57
58
# File 'app/models/course/settings/leaderboard_component.rb', line 56

def group_leaderboard_title
  group_leaderboard_settings.title
end

#group_leaderboard_title=(group_leaderboard_title) ⇒ Object

Sets the title of group leaderboard

Parameters:

  • title (String)

    The new title


63
64
65
66
# File 'app/models/course/settings/leaderboard_component.rb', line 63

def group_leaderboard_title=(group_leaderboard_title)
  group_leaderboard_title = nil if group_leaderboard_title.blank?
  group_leaderboard_settings.title = group_leaderboard_title
end

#titleString

Returns the title of leaderboard component

Returns:

  • (String)

    The custom or default title of leaderboard component


10
11
12
# File 'app/models/course/settings/leaderboard_component.rb', line 10

def title
  settings.title
end

#title=(title) ⇒ Object

Sets the title of leaderboard component

Parameters:

  • title (String)

    The new title


17
18
19
20
# File 'app/models/course/settings/leaderboard_component.rb', line 17

def title=(title)
  title = nil if title.blank?
  settings.title = title
end