Class: Avo::Current

Inherits:
ActiveSupport::CurrentAttributes
  • Object
show all
Defined in:
lib/avo/current.rb

Instance Method Summary collapse

Instance Method Details

#paramsObject

Protect from error #<RuntimeError: Missing rack.input> when request is ActionDispatch::Request.empty



18
19
20
21
22
# File 'lib/avo/current.rb', line 18

def params
  request.params
rescue
  {}
end

#requestObject



24
25
26
# File 'lib/avo/current.rb', line 24

def request
  view_context&.request || ActionDispatch::Request.empty
end

#user_is_admin?Boolean

Returns:

  • (Boolean)


28
29
30
31
32
# File 'lib/avo/current.rb', line 28

def user_is_admin?
  return false unless user&.respond_to?(Avo.configuration.is_admin_method)

  user.send(Avo.configuration.is_admin_method)
end

#user_is_developer?Boolean

Returns:

  • (Boolean)


34
35
36
37
38
# File 'lib/avo/current.rb', line 34

def user_is_developer?
  return false unless user&.respond_to?(Avo.configuration.is_developer_method)

  user.send(Avo.configuration.is_developer_method)
end