Class: Avo::Current
- Inherits:
-
ActiveSupport::CurrentAttributes
- Object
- ActiveSupport::CurrentAttributes
- Avo::Current
- Defined in:
- lib/avo/current.rb
Instance Method Summary collapse
-
#params ⇒ Object
Protect from error #<RuntimeError: Missing rack.input> when request is ActionDispatch::Request.empty.
- #request ⇒ Object
- #user_is_admin? ⇒ Boolean
- #user_is_developer? ⇒ Boolean
Instance Method Details
#params ⇒ Object
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 |
#request ⇒ Object
24 25 26 |
# File 'lib/avo/current.rb', line 24 def request view_context&.request || ActionDispatch::Request.empty end |
#user_is_admin? ⇒ 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
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 |