Module: Permissify::Common

Included in:
Controller, Union
Defined in:
lib/permissify/common.rb

Instance Method Summary collapse

Instance Method Details

#allowed_to?(action, ability_category) ⇒ Boolean

Returns:

  • (Boolean)


4
5
6
# File 'lib/permissify/common.rb', line 4

def allowed_to?(action, ability_category)
  permission(action, ability_category) == true
end

#createable?(ability_category) ⇒ Boolean

Returns:

  • (Boolean)


9
# File 'lib/permissify/common.rb', line 9

def createable?(ability_category);     allowed_to?(:create,  ability_category); end

#deleteable?(ability_category) ⇒ Boolean

Returns:

  • (Boolean)


11
# File 'lib/permissify/common.rb', line 11

def deleteable?(ability_category);     allowed_to?(:delete,  ability_category); end

#log_permissionsObject



19
20
21
22
# File 'lib/permissify/common.rb', line 19

def log_permissions
  message = "*** PermissifyController permissions: #{@permissions.inspect}"
  defined?(logger) ? logger.debug(message) : puts(message)
end

#permissible?(permissions_hash, action, category) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/permissify/common.rb', line 14

def permissible?(permissions_hash, action, category)
  key = Ability.key_for(action, category)
  (permission = permissions_hash[key]) && permission['0'] == true
end

#subscribed_to?(ability_category) ⇒ Boolean

Returns:

  • (Boolean)


12
# File 'lib/permissify/common.rb', line 12

def subscribed_to?(ability_category);  allowed_to?(:on,      ability_category); end

#updateable?(ability_category) ⇒ Boolean

Returns:

  • (Boolean)


10
# File 'lib/permissify/common.rb', line 10

def updateable?(ability_category);     allowed_to?(:update,  ability_category); end

#viewable?(ability_category) ⇒ Boolean

Returns:

  • (Boolean)


8
# File 'lib/permissify/common.rb', line 8

def viewable?(ability_category);       allowed_to?(:view,    ability_category); end