Class: CanTango::PermissionEngine::Loader::Permissions
- Defined in:
- lib/cantango/permission_engine/loader/permissions.rb
Instance Attribute Summary collapse
-
#permissions ⇒ Object
Returns the value of attribute permissions.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(file_name) ⇒ Permissions
constructor
A new instance of Permissions.
- #load! ⇒ Object
- #load_from_hash(hash) ⇒ Object
- #parser ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(file_name) ⇒ Permissions
Returns a new instance of Permissions.
7 8 9 10 |
# File 'lib/cantango/permission_engine/loader/permissions.rb', line 7 def initialize file_name @file_name = file_name load! end |
Instance Attribute Details
#permissions ⇒ Object
Returns the value of attribute permissions.
5 6 7 |
# File 'lib/cantango/permission_engine/loader/permissions.rb', line 5 def @permissions end |
Instance Method Details
#load! ⇒ Object
27 28 29 30 31 |
# File 'lib/cantango/permission_engine/loader/permissions.rb', line 27 def load! load_from_hash yml_content rescue => e raise "PermissionsLoader Error: The permissions for the file #{file_name} could not be loaded - cause was #{e}" end |
#load_from_hash(hash) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/cantango/permission_engine/loader/permissions.rb', line 12 def load_from_hash hash return if hash.empty? hash.each do |type, groups| [type] ||= {} next if groups.nil? groups.each do |group, rules| parser.parse(group, rules) do || [type][.name] = end end end end |
#parser ⇒ Object
37 38 39 |
# File 'lib/cantango/permission_engine/loader/permissions.rb', line 37 def parser @parser ||= CanTango::PermissionEngine::Parser::Permissions.new end |