Class: MkAcl::Rule
- Inherits:
-
Object
- Object
- MkAcl::Rule
- Defined in:
- lib/mikras_utils/mkacl/spec.rb
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#assert ⇒ Object
Goes into the postgres trigger, may be nil.
-
#fields ⇒ Object
Only used for insert and update, nil otherwise.
-
#filter ⇒ Object
Goes into the postgres policy, may be nil.
-
#function ⇒ Object
Implementation function, may be nil.
-
#mutation ⇒ Object
Mutation function, may be nil.
-
#ordinal ⇒ Object
readonly
Returns the value of attribute ordinal.
-
#roles ⇒ Object
Roles that this rule applies to.
-
#stamp_exprs ⇒ Object
Returns the value of attribute stamp_exprs.
-
#stamps ⇒ Object
Returns the value of attribute stamps.
-
#tables ⇒ Object
Only used for attach and detach, nil otherwise.
Instance Method Summary collapse
-
#auth_roles ⇒ Object
admin, internal, etc.
-
#case_roles ⇒ Object
KON, AKK, etc.
- #dump ⇒ Object
-
#initialize(action, ordinal) ⇒ Rule
constructor
A new instance of Rule.
Constructor Details
#initialize(action, ordinal) ⇒ Rule
Returns a new instance of Rule.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 227 def initialize(action, ordinal) @action = action @ordinal = ordinal @roles = [] @filter = nil @assert = nil # @mutation = (action.name == "select" ? nil : "#{action}_#{table.record_name}") @mutation = default_mutation @function = nil #(action.name == "select" ? nil : DEFAULT_MUTATION) @fields = %w(insert update).include?(action.name) ? [] : nil @tables = %w(attach detach).include?(action.name) ? [] : nil @stamps = [] @stamp_exprs = [] action.send :attach_rule, self end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
192 193 194 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 192 def action @action end |
#assert ⇒ Object
Goes into the postgres trigger, may be nil
202 203 204 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 202 def assert @assert end |
#fields ⇒ Object
Only used for insert and update, nil otherwise
212 213 214 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 212 def fields @fields end |
#filter ⇒ Object
Goes into the postgres policy, may be nil
199 200 201 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 199 def filter @filter end |
#function ⇒ Object
Implementation function, may be nil. Default ‘app_portal.mutate()’ except attach/detach
209 210 211 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 209 def function @function end |
#mutation ⇒ Object
Mutation function, may be nil. Default create/update/delete_RECORD except select/attach/detach
206 207 208 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 206 def mutation @mutation end |
#ordinal ⇒ Object (readonly)
Returns the value of attribute ordinal.
219 220 221 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 219 def ordinal @ordinal end |
#roles ⇒ Object
Roles that this rule applies to
196 197 198 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 196 def roles @roles end |
#stamp_exprs ⇒ Object
Returns the value of attribute stamp_exprs.
218 219 220 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 218 def stamp_exprs @stamp_exprs end |
#stamps ⇒ Object
Returns the value of attribute stamps.
217 218 219 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 217 def stamps @stamps end |
#tables ⇒ Object
Only used for attach and detach, nil otherwise
215 216 217 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 215 def tables @tables end |
Instance Method Details
#auth_roles ⇒ Object
admin, internal, etc.
222 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 222 def auth_roles() @auth_roles ||= roles.select { _1 == _1.downcase } end |
#case_roles ⇒ Object
KON, AKK, etc.
225 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 225 def case_roles() @case_roles ||= roles.select { _1 == _1.upcase } end |
#dump ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'lib/mikras_utils/mkacl/spec.rb', line 244 def dump puts "roles: #{roles.join(' ')}" puts "tables: #{tables.join(' ')}" if tables && !tables.empty? puts "filter: #{filter}" if filter puts "assert: #{assert}" if assert if %w(insert update delete).include?(action.name) puts "mutation: #{mutation || 'nil'}" \ if name != 'select' && (mutation.nil? || mutation != default_mutation) puts "function: #{function || 'nil'}" if name != 'select' && function != DEFAULT_FUNCTION else puts "function: #{function}" if function end puts "fields: #{fields.join(' ')}" if fields && !fields.empty? if stamp_exprs.size == 1 stamp_exprs.first.dump elsif stamp_exprs.size > 1 puts "stamps:" indent { for stamp_expr in stamp_exprs print "- " indent(bol: false) { stamp_expr.dump } end } end puts "ordinal: #{ordinal}" end |