Class: AccessAllow::Abilities
- Inherits:
-
Object
- Object
- AccessAllow::Abilities
- Defined in:
- lib/access_allow/abilities.rb
Class Method Summary collapse
- .humanized_name(type, ability_namespace, ability_name) ⇒ Object
- .parse_qualified_name(name) ⇒ Object
- .qualified_name(ability_namespace, ability_name) ⇒ Object
Class Method Details
.humanized_name(type, ability_namespace, ability_name) ⇒ Object
20 21 22 |
# File 'lib/access_allow/abilities.rb', line 20 def humanized_name(type, ability_namespace, ability_name) I18n.t("abilities.#{type}.abilities.#{ability_namespace}.#{ability_name}") end |
.parse_qualified_name(name) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/access_allow/abilities.rb', line 11 def parse_qualified_name(name) parts = name.split("/").map do |part| raise StandardError "Ability namespaces or names cannot be blank" if part.blank? part.to_sym end return parts if parts.size == 2 raise StandardError "Ability name must have a namespace and name (was #{name})" end |
.qualified_name(ability_namespace, ability_name) ⇒ Object
6 7 8 9 |
# File 'lib/access_allow/abilities.rb', line 6 def qualified_name(ability_namespace, ability_name) raise StandardError, "You can't have blank ability names" if ability_namespace.blank? || ability_name.blank? "#{ability_namespace}/#{ability_name}" end |