Class: Decidim::ActionAuthorizer::AuthorizationStatus

Inherits:
Object
  • Object
show all
Defined in:
decidim-core/app/services/decidim/action_authorizer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, authorization_handler, data) ⇒ AuthorizationStatus

Returns a new instance of AuthorizationStatus.


57
58
59
60
61
# File 'decidim-core/app/services/decidim/action_authorizer.rb', line 57

def initialize(code, authorization_handler, data)
  @code = code.to_sym
  @authorization_handler = authorization_handler
  @data = data.symbolize_keys
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code


55
56
57
# File 'decidim-core/app/services/decidim/action_authorizer.rb', line 55

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data


55
56
57
# File 'decidim-core/app/services/decidim/action_authorizer.rb', line 55

def data
  @data
end

Instance Method Details

#current_path(redirect_url: nil) ⇒ Object


63
64
65
66
67
68
69
70
71
# File 'decidim-core/app/services/decidim/action_authorizer.rb', line 63

def current_path(redirect_url: nil)
  return unless @authorization_handler

  if pending?
    @authorization_handler.resume_authorization_path(redirect_url: redirect_url)
  else
    @authorization_handler.root_path(redirect_url: redirect_url)
  end
end

#handler_nameObject


73
74
75
76
77
# File 'decidim-core/app/services/decidim/action_authorizer.rb', line 73

def handler_name
  return unless @authorization_handler

  @authorization_handler.key
end

#ok?Boolean

Returns:

  • (Boolean)

79
80
81
# File 'decidim-core/app/services/decidim/action_authorizer.rb', line 79

def ok?
  @code == :ok
end

#pending?Boolean

Returns:

  • (Boolean)

83
84
85
# File 'decidim-core/app/services/decidim/action_authorizer.rb', line 83

def pending?
  @code == :pending
end

#unauthorized?Boolean

Returns:

  • (Boolean)

87
88
89
# File 'decidim-core/app/services/decidim/action_authorizer.rb', line 87

def unauthorized?
  @code == :unauthorized
end