Class: Socialmux::Strategy

Inherits:
Object
  • Object
show all
Defined in:
lib/socialmux/strategy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Strategy



11
12
13
14
15
16
17
18
19
20
# File 'lib/socialmux/strategy.rb', line 11

def initialize(options)
  options.assert_valid_keys(:adapter,
                            :current_user,
                            :omniauth_data,
                            :user_params)

  options.each do |key, value|
    instance_variable_set "@#{key}", value
  end
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



6
7
8
# File 'lib/socialmux/strategy.rb', line 6

def adapter
  @adapter
end

#current_userObject (readonly)

Returns the value of attribute current_user.



7
8
9
# File 'lib/socialmux/strategy.rb', line 7

def current_user
  @current_user
end

#omniauth_dataObject (readonly)

Returns the value of attribute omniauth_data.



8
9
10
# File 'lib/socialmux/strategy.rb', line 8

def omniauth_data
  @omniauth_data
end

#user_paramsObject (readonly)

Returns the value of attribute user_params.



9
10
11
# File 'lib/socialmux/strategy.rb', line 9

def user_params
  @user_params
end

Instance Method Details

#dataObject



29
30
31
# File 'lib/socialmux/strategy.rb', line 29

def data
  @data ||= AuthMapper.init_with_data(omniauth_data)
end

#resultObject



22
23
24
25
26
27
# File 'lib/socialmux/strategy.rb', line 22

def result
  returning_user ||
  augmented_current_user ||
  augmented_user_with_same_email ||
  new_user
end