Sha256: 2079547ca25f4b762559ad7eb6cb7671fcc5a739d44a5817fc502e974310eb6d

Contents?: true

Size: 719 Bytes

Versions: 1

Compression:

Stored size: 719 Bytes

Contents

module Omnisocial
  class LoginAccount
    include Mongoid::Document
    include Mongoid::Timestamps
    
    referenced_in :user
  
    field :token
    field :secret
    field :remote_account_id
    field :name
    field :login
    field :picture_url
  
    def self.find_or_create_from_auth_hash(auth_hash)
      if (account = first(:conditions => {:remote_account_id => auth_hash['uid']}))
        account.assign_account_info(auth_hash)
        account.save
        account
      else
        create_from_auth_hash(auth_hash)
      end
    end
  
    def self.create_from_auth_hash(auth_hash)
      account = create!
      account.assign_account_info(auth_hash)
      account.save
      account
    end
  
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cornflakeomnisocial-0.1.2.3 app/models/omnisocial/login_account.rb