Sha256: f7351b04547948d736d05526568df4372a405acdcdbb28de2239d6eaaab6767a

Contents?: true

Size: 452 Bytes

Versions: 8

Compression:

Stored size: 452 Bytes

Contents

class Authorization < ActiveRecord::Base
  belongs_to :user
  validates_presence_of :user_id, :uid, :provider
  validates_uniqueness_of :uid, :scope => :provider

  def self.find_from_hash(hash)
    find_by_provider_and_uid(hash['provider'], hash['uid'])
  end

  def self.create_from_hash(hash, user = nil)
    user ||= User.create_from_hash!(hash)
    Authorization.create(:user => user, :uid => hash['uid'], :provider => hash['provider'])
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
echo_base-0.2.1 lib/templates/app/models/authorization.rb
echo_base-0.1.3 lib/generators/echo_base/templates/app/models/authorization.rb
echo_base-0.1.2 lib/generators/echo_base/templates/app/models/authorization.rb
echo_base-0.1.1 lib/generators/echo_base/templates/app/models/authorization.rb
echo_base-0.1.0 lib/generators/echo_base/templates/app/models/authorization.rb
echo_base-0.0.4 lib/generators/echo_base/templates/app/models/authorization.rb
echo_base-0.0.3 lib/generators/echo_base/templates/app/models/authorization.rb
echo_base-0.0.2 lib/generators/echo_base/templates/app/models/authorization.rb