2021-04-29 21:17:54 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# This class stores all the information needed to display and
|
|
|
|
# render the sidebar and menus.
|
|
|
|
# It usually stores information regarding the context and calculated
|
|
|
|
# values where the logic is in helpers.
|
|
|
|
module Sidebars
|
|
|
|
class Context
|
2023-05-27 22:25:52 +05:30
|
|
|
attr_reader :current_user, :container, :route_is_active, :is_super_sidebar
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
def initialize(current_user:, container:, **args)
|
|
|
|
@current_user = current_user
|
|
|
|
@container = container
|
2023-05-27 22:25:52 +05:30
|
|
|
@is_super_sidebar = false
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
args.each do |key, value|
|
|
|
|
singleton_class.public_send(:attr_reader, key) # rubocop:disable GitlabSecurity/PublicSend
|
|
|
|
instance_variable_set("@#{key}", value)
|
|
|
|
end
|
2023-05-27 22:25:52 +05:30
|
|
|
|
|
|
|
@route_is_active ||= ->(_) { false }
|
2021-04-29 21:17:54 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|