Class: Decidim::ActionAuthorizer::AuthorizationStatus

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, handler_name, data) ⇒ AuthorizationStatus

Returns a new instance of AuthorizationStatus.



102
103
104
105
106
# File 'app/services/decidim/action_authorizer.rb', line 102

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



100
101
102
# File 'app/services/decidim/action_authorizer.rb', line 100

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



100
101
102
# File 'app/services/decidim/action_authorizer.rb', line 100

def data
  @data
end

Instance Method Details

#auth_methodObject



108
109
110
111
112
# File 'app/services/decidim/action_authorizer.rb', line 108

def auth_method
  return unless @handler_name

  @auth_method ||= Verifications::Adapter.from_element(@handler_name)
end

#current_path(redirect_url: nil) ⇒ Object



114
115
116
117
118
119
120
121
122
# File 'app/services/decidim/action_authorizer.rb', line 114

def current_path(redirect_url: nil)
  return unless auth_method

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

#handler_nameObject



124
125
126
127
128
# File 'app/services/decidim/action_authorizer.rb', line 124

def handler_name
  return unless auth_method

  auth_method.key
end

#ok?Boolean

Returns:

  • (Boolean)


130
131
132
# File 'app/services/decidim/action_authorizer.rb', line 130

def ok?
  @code == :ok
end

#pending?Boolean

Returns:

  • (Boolean)


134
135
136
# File 'app/services/decidim/action_authorizer.rb', line 134

def pending?
  @code == :pending
end