Class: CanTango::PermissionEngine::Loader::Categories
- Defined in:
- lib/cantango/permission_engine/loader/categories.rb
Instance Attribute Summary collapse
-
#categories ⇒ Object
readonly
Returns the value of attribute categories.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
Instance Method Summary collapse
- #categories_config_file ⇒ Object
- #category(name) ⇒ Object
- #config_path ⇒ Object
- #get_config_file(name) ⇒ Object
-
#initialize(file = nil) ⇒ Categories
constructor
A new instance of Categories.
- #load_categories(name = nil) ⇒ Object
- #parser ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(file = nil) ⇒ Categories
Returns a new instance of Categories.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 7 def initialize file = nil begin @file_name = file || categories_config_file yml_content.each do |key, value| parser.parse(categories, key, value) end rescue RuntimeError => e raise "CanTango::Categories::Loader Error: The categories for the file #{file_name} could not be loaded - cause was #{e}" end end |
Instance Attribute Details
#categories ⇒ Object (readonly)
Returns the value of attribute categories.
5 6 7 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 5 def categories @categories end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
5 6 7 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 5 def file_name @file_name end |
Instance Method Details
#categories_config_file ⇒ Object
36 37 38 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 36 def categories_config_file get_config_file 'categories' end |
#category(name) ⇒ Object
19 20 21 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 19 def category name categories.category(name).subjects end |
#config_path ⇒ Object
44 45 46 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 44 def config_path CanTango.config..config_path end |
#get_config_file(name) ⇒ Object
40 41 42 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 40 def get_config_file name File.join(config_path, "#{name}.yml") end |
#load_categories(name = nil) ⇒ Object
31 32 33 34 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 31 def load_categories name = nil name ||= categories_config_file CanTango::Categories::Loader.new name end |
#parser ⇒ Object
27 28 29 |
# File 'lib/cantango/permission_engine/loader/categories.rb', line 27 def parser @parser ||= CanTango::PermissionEngine::Parser::Categories.new end |