Module: Platform::SimpleStringPermissions

Included in:
Application
Defined in:
lib/platform/simple_string_permissions.rb

Instance Method Summary collapse

Instance Method Details

#has_permission?(key) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/platform/simple_string_permissions.rb', line 35

def has_permission?(key)
  permissions.to_s.split(',').include?(key.to_s)
end

#set_permission(key, value) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/platform/simple_string_permissions.rb', line 27

def set_permission(key, value)
  self.permissions = if value
    (permissions.to_s.split(',').to_set + key.to_s)
  else
    (permissions.to_s.split(',').to_set - key.to_s)
  end.join(',')
end