Class: Mkxms::Mssql::PermissionGroup
- Inherits:
-
Object
- Object
- Mkxms::Mssql::PermissionGroup
- Defined in:
- lib/mkxms/mssql/permission_handler.rb
Constant Summary collapse
- ACTION_STATEMENT_PROLOG_TEMPLATES =
{ 'granted' => 'GRANT %s ON %s TO %s', 'denied' => 'DENY %s ON %s TO %s', }
Instance Attribute Summary collapse
-
#action ⇒ Object
Returns the value of attribute action.
-
#permissions ⇒ Object
readonly
Returns the value of attribute permissions.
-
#subject ⇒ Object
Returns the value of attribute subject.
Instance Method Summary collapse
-
#initialize(action, subject) ⇒ PermissionGroup
constructor
A new instance of PermissionGroup.
- #is_super_permission?(p) ⇒ Boolean
- #regular_permissions ⇒ Object
- #regular_permissions_graph ⇒ Object
- #super_permissions ⇒ Object
- #super_permissions_sql ⇒ Object
Constructor Details
#initialize(action, subject) ⇒ PermissionGroup
Returns a new instance of PermissionGroup.
12 13 14 15 16 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 12 def initialize(action, subject) @action = action @subject = subject @permissions = [] end |
Instance Attribute Details
#action ⇒ Object
Returns the value of attribute action.
18 19 20 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 18 def action @action end |
#permissions ⇒ Object (readonly)
Returns the value of attribute permissions.
19 20 21 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 19 def @permissions end |
#subject ⇒ Object
Returns the value of attribute subject.
18 19 20 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 18 def subject @subject end |
Instance Method Details
#is_super_permission?(p) ⇒ Boolean
39 40 41 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 39 def (p) action != 'granted' || p.grant_option? end |
#regular_permissions ⇒ Object
47 48 49 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 47 def .select {|p| ! p} end |
#regular_permissions_graph ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 31 def Hash.new.tap do |result| .sort {|a, b| a.target <=> b.target}.group_by {|p| p.target}.each_pair do |target, perms| result[target] = perms.map(&:name) end end end |
#super_permissions ⇒ Object
43 44 45 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 43 def .select {|p| p} end |
#super_permissions_sql ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/mkxms/mssql/permission_handler.rb', line 21 def .map do |p| ''.tap do |sql| sql << ACTION_STATEMENT_PROLOG_TEMPLATES[action] % [p.name, p.target, subject] sql << ' WITH GRANT OPTION' if p.grant_option? sql << ';' end end end |