Class: ForestLiana::PermissionsChecker

Inherits:
Object
  • Object
show all
Defined in:
app/services/forest_liana/permissions_checker.rb

Constant Summary collapse

@@permissions_per_rendering =
Hash.new
@@expiration_in_seconds =
(ENV['FOREST_PERMISSIONS_EXPIRATION_IN_SECONDS'] || 3600).to_i

Instance Method Summary collapse

Constructor Details

#initialize(resource, permission_name, rendering_id) ⇒ PermissionsChecker

Returns a new instance of PermissionsChecker.



6
7
8
9
10
# File 'app/services/forest_liana/permissions_checker.rb', line 6

def initialize(resource, permission_name, rendering_id)
  @collection_name = ForestLiana.name_for(resource)
  @permission_name = permission_name
  @rendering_id = rendering_id
end

Instance Method Details

#is_authorized?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/services/forest_liana/permissions_checker.rb', line 12

def is_authorized?
  (is_permission_expired? || !is_allowed?) ? retrieve_permissions_and_check_allowed : true
end