Class: Providers::BaseManager

Inherits:
Object
  • Object
show all
Defined in:
app/models/providers/base_manager.rb

Direct Known Subclasses

GithubManager

Constant Summary collapse

SPIN_SCHEMA =
Rails.application.config.spin_schema.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ BaseManager


8
9
10
11
12
13
# File 'app/models/providers/base_manager.rb', line 8

def initialize(user)
  @identifier = user ? user.authentication_tokens.first.provider : nil
  @provider = get_provider(@identifier)
  @provider_token = user ? user.authentication_tokens.first.github_token : nil
  @provider_user = user || nil
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier


4
5
6
# File 'app/models/providers/base_manager.rb', line 4

def identifier
  @identifier
end

#providerObject (readonly)

Returns the value of attribute provider


4
5
6
# File 'app/models/providers/base_manager.rb', line 4

def provider
  @provider
end

Instance Method Details

#get_connectorObject


15
16
17
18
19
20
21
# File 'app/models/providers/base_manager.rb', line 15

def get_connector
  return @provider if @provider.kind_of? ErrorExchange
  case @provider[:type].downcase
  when 'github' then Providers::GithubManager.new(@provider)
  else ErrorExchange.new(:provider_name_not_provided, :bad_request, {})
  end
end

#validate_provider(identifier) ⇒ Object


23
24
25
26
27
28
# File 'app/models/providers/base_manager.rb', line 23

def validate_provider(identifier)
  pr = get_provider(identifier)
  @provider = pr
  return pr if pr.kind_of? ErrorExchange
  true
end