Module: BookingSync::Engine::Model::ClassMethods

Defined in:
lib/bookingsync/engine/model.rb

Instance Method Summary collapse

Instance Method Details

#from_omniauth(auth) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/bookingsync/engine/model.rb', line 5

def from_omniauth(auth)
  auth_params = auth.slice(:provider, :uid).permit(:provider, :uid)
  where(auth_params).first_or_initialize.tap do ||
    .provider  = auth.provider
    .uid       = auth.uid
    .name      = auth.info.business_name

    .update_token(auth.credentials)

    .save!
  end
end