Module: CapabilityAware

Extended by:
ActiveSupport::Concern
Included in:
ConsoleController
Defined in:
app/controllers/capability_aware.rb

Instance Method Summary collapse

Instance Method Details

#user_capabilities(args = {}) ⇒ Object

Call this with :refresh => true to force a refresh of the values stored in session



10
11
12
13
14
15
# File 'app/controllers/capability_aware.rb', line 10

def user_capabilities(args = {})
  @user_capabilities = nil if args[:refresh]
  @user_capabilities ||=
    (Capabilities::Cacheable.from(session[:user_capabilities]) rescue nil) ||
    User.find(:one, :as => current_user).to_capabilities.tap{ |c| session[:user_capabilities] = c.to_a }
end