module Avo::InitializesAvo

def _current_user

def _current_user
  instance_eval(&Avo.configuration.current_user)
end

def context

def context
  instance_eval(&Avo.configuration.context)
end

def init_app

def init_app
  Avo::Current.license = Avo::Licensing::NilLicense.new
  Avo::Current.context = context
  Avo::Current.user = _current_user
  Avo::Current.view_context = view_context
  Avo.init
  Avo::Current.license = Licensing::LicenseManager.new(Licensing::HQ.new(request).response).license
  # Output a warning in the logs if the license is invalid
  if Avo::Current.license.invalid?
    Avo.logger.debug "Your Avo license looks invalid. Please troubleshoot it using the directions here: https://docs.avohq.io/3.0/license-troubleshooting.html"
  end
  Avo::Current.locale = locale
end