Class: Formol::Permissions::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/formol/permissions/manager.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ Manager

Returns a new instance of Manager.



7
8
9
10
# File 'lib/formol/permissions/manager.rb', line 7

def initialize(user)
  self.user = user
  @profile_name = (user && user.persisted? ? user.formol_profile : :default).to_sym
end

Instance Attribute Details

#userObject

Returns the value of attribute user.



4
5
6
# File 'lib/formol/permissions/manager.rb', line 4

def user
  @user
end

Instance Method Details

#able_to?(right, obj = nil) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
16
# File 'lib/formol/permissions/manager.rb', line 12

def able_to?(right, obj = nil)
  return true if has_right?(:administrate)
  
  respond_to?(m = :"able_to_#{right}?") ? send(m, obj) : has_right?(right)
end