Class: SkillTree::Parser::RoleParser
- Inherits:
-
Object
- Object
- SkillTree::Parser::RoleParser
- Defined in:
- lib/skill_tree/parser/role_parser.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
writeonly
Sets the attribute parent.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
Instance Method Summary collapse
- #can(*args) ⇒ Object
- #inherit(name) ⇒ Object
-
#initialize(name) ⇒ RoleParser
constructor
A new instance of RoleParser.
- #sync_model(acl) ⇒ Object
Constructor Details
#initialize(name) ⇒ RoleParser
Returns a new instance of RoleParser.
6 7 8 9 |
# File 'lib/skill_tree/parser/role_parser.rb', line 6 def initialize(name) @name = name.to_s = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/skill_tree/parser/role_parser.rb', line 4 def name @name end |
#parent=(value) ⇒ Object (writeonly)
Sets the attribute parent
5 6 7 |
# File 'lib/skill_tree/parser/role_parser.rb', line 5 def parent=(value) @parent = value end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
4 5 6 |
# File 'lib/skill_tree/parser/role_parser.rb', line 4 def end |
Instance Method Details
#can(*args) ⇒ Object
11 12 13 |
# File 'lib/skill_tree/parser/role_parser.rb', line 11 def can(*args) += args end |
#inherit(name) ⇒ Object
15 16 17 18 19 |
# File 'lib/skill_tree/parser/role_parser.rb', line 15 def inherit(name) element = @parent.roles.select { |e| e.name == name.to_s }.first fail "There is no #{name} role" if element.nil? += element. end |
#sync_model(acl) ⇒ Object
21 22 23 24 25 |
# File 'lib/skill_tree/parser/role_parser.rb', line 21 def sync_model(acl) role = SkillTree::Models::Role.find_or_initialize_by(name: @name) role.save! (acl, role) end |