Class: LogicalAuthz::AccessControl::Owner

Inherits:
Policy
  • Object
show all
Defined in:
lib/logical_authz/access_control.rb

Instance Attribute Summary

Attributes inherited from Policy

#decision, #name

Instance Method Summary collapse

Methods inherited from Policy

#evaluate, #laz_debug, names, register

Constructor Details

#initialize(&map_owner) ⇒ Owner

Returns a new instance of Owner.



306
307
308
309
# File 'lib/logical_authz/access_control.rb', line 306

def initialize(&map_owner)
  @mapper = map_owner
  super()
end

Instance Method Details

#check(criteria) ⇒ Object



315
316
317
318
319
320
321
322
# File 'lib/logical_authz/access_control.rb', line 315

def check(criteria)
  return false unless criteria.has_key?(:user) and criteria.has_key?(:id)
  unless @mapper.nil?
    @mapper.call(criteria[:user], criteria[:id].to_i)
  else
    criteria[:user].id == criteria[:id].to_i
  end
end

#default_nameObject



311
312
313
# File 'lib/logical_authz/access_control.rb', line 311

def default_name
  "Related"
end