Class: ForestLiana::Utils::ContextVariables

Inherits:
Object
  • Object
show all
Defined in:
app/services/forest_liana/utils/context_variables.rb

Constant Summary collapse

USER_VALUE_PREFIX =
'currentUser.'.freeze
USER_VALUE_TAG_PREFIX =
'currentUser.tags.'.freeze
USER_VALUE_TEAM_PREFIX =
'currentUser.team.'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(team, user, request_context_variables = nil) ⇒ ContextVariables

Returns a new instance of ContextVariables.



12
13
14
15
16
# File 'app/services/forest_liana/utils/context_variables.rb', line 12

def initialize(team, user, request_context_variables = nil)
  @team = team
  @user = user
  @request_context_variables = request_context_variables
end

Instance Attribute Details

#request_context_variablesObject (readonly)

Returns the value of attribute request_context_variables.



4
5
6
# File 'app/services/forest_liana/utils/context_variables.rb', line 4

def request_context_variables
  @request_context_variables
end

#teamObject (readonly)

Returns the value of attribute team.



4
5
6
# File 'app/services/forest_liana/utils/context_variables.rb', line 4

def team
  @team
end

#userObject (readonly)

Returns the value of attribute user.



4
5
6
# File 'app/services/forest_liana/utils/context_variables.rb', line 4

def user
  @user
end

Instance Method Details

#get_value(context_variable_key) ⇒ Object



18
19
20
21
22
# File 'app/services/forest_liana/utils/context_variables.rb', line 18

def get_value(context_variable_key)
  return get_current_user_data(context_variable_key) if context_variable_key.start_with?(USER_VALUE_PREFIX)

  request_context_variables[context_variable_key] if request_context_variables
end