Class: Course::Settings::SidebarItem

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model, ActiveModel::Validations
Defined in:
app/models/course/settings/sidebar_item.rb

Instance Method Summary collapse

Constructor Details

#initialize(settings, sidebar_item) ⇒ SidebarItem

Returns a new instance of SidebarItem

Parameters:

  • settings (#settings)

    The scoped settings object.

  • sidebar_item (Hash)

    The hash which contains the attributes of sidebar item.


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

def initialize(settings, sidebar_item)
  @settings = settings
  @sidebar_item = sidebar_item
end

Instance Method Details

#idString

Returns The unique id(key) of the item.

Returns:

  • (String)

    The unique id(key) of the item.


16
17
18
# File 'app/models/course/settings/sidebar_item.rb', line 16

def id
  @sidebar_item[:key]
end

#titleString

Returns The title of the item.

Returns:

  • (String)

    The title of the item.


21
22
23
# File 'app/models/course/settings/sidebar_item.rb', line 21

def title
  @sidebar_item[:title]
end

#weightInteger

Returns The weight of the item.

Returns:

  • (Integer)

    The weight of the item.


26
27
28
29
# File 'app/models/course/settings/sidebar_item.rb', line 26

def weight
  result = @settings.settings(id).weight if id
  result || @sidebar_item[:weight]
end