Module: Rabarber::Core::Roleable

Included in:
Authorization, Helpers
Defined in:
lib/rabarber/core/roleable.rb

Instance Method Summary collapse

Instance Method Details

#roleableObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rabarber/core/roleable.rb', line 6

def roleable
  current_roleable = send(Rabarber::Configuration.current_user_method)

  unless current_roleable.is_a?(Rabarber::Configuration.user_model)
    raise(
      Rabarber::Error,
      "Expected `#{Rabarber::Configuration.current_user_method}` to return an instance of #{Rabarber::Configuration.user_model_name}, got #{current_roleable.inspect}"
    )
  end

  current_roleable
end

#roleable_roles(context: nil) ⇒ Object



19
20
21
# File 'lib/rabarber/core/roleable.rb', line 19

def roleable_roles(context: nil)
  roleable.roles(context:)
end