Module: FatModelAuth::ViewHelpers

Defined in:
lib/fat_model_auth/view_helpers.rb

Instance Method Summary collapse

Instance Method Details

#allowed_to?(options) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



5
6
7
8
9
10
11
12
# File 'lib/fat_model_auth/view_helpers.rb', line 5

def allowed_to?(options)
  actions, authority = options.first
  raise FatModelAuth::AuthException, "#{authority.inspect} is nil" if authority.nil?

  actions.to_s.split('_or_').any? do |action|
    authority.allows(current_user).send("to_#{action}?")
  end
end