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.


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

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.


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

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.


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

def data
  @data
end

Instance Method Details

#current_path(redirect_url: nil) ⇒ Object


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

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


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

def handler_name
  return unless @authorization_handler

  @authorization_handler.key
end

#ok?Boolean

Returns:

  • (Boolean)

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

def ok?
  @code == :ok
end

#pending?Boolean

Returns:

  • (Boolean)

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

def pending?
  @code == :pending
end

#unauthorized?Boolean

Returns:

  • (Boolean)

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

def unauthorized?
  @code == :unauthorized
end