Module: Rolypoly::ControllerRoleDSL::InstanceMethods

Defined in:
lib/rolypoly/controller_role_dsl.rb

Instance Method Summary collapse

Instance Method Details

#allow?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/rolypoly/controller_role_dsl.rb', line 49

def allow?(options = {})
  rolypoly_gatekeepers.allow?(current_roles, action_name, rolypoly_resource_map.merge(options))
end

#current_gatekeepersObject



43
44
45
46
47
# File 'lib/rolypoly/controller_role_dsl.rb', line 43

def current_gatekeepers
  rolypoly_gatekeepers.select { |gatekeeper|
    gatekeeper.action? action_name
  }
end

#current_rolesObject



33
34
35
36
37
# File 'lib/rolypoly/controller_role_dsl.rb', line 33

def current_roles
  return [] if rolypoly_gatekeepers.empty?

  allowed_roles(action_name)
end

#failed_role_check!Object



29
30
31
# File 'lib/rolypoly/controller_role_dsl.rb', line 29

def failed_role_check!
  raise Rolypoly::FailedRoleCheckError
end

#public?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/rolypoly/controller_role_dsl.rb', line 39

def public?
  super(action_name)
end

#rolypoly_check_role_access!Object



25
26
27
# File 'lib/rolypoly/controller_role_dsl.rb', line 25

def rolypoly_check_role_access!
  failed_role_check! unless rolypoly_role_access?
end