Sha256: 58dadd70b0a4645fe4b8962d4334978296ea57c5c0c0a58bb4842434e9046deb

Contents?: true

Size: 389 Bytes

Versions: 31

Compression:

Stored size: 389 Bytes

Contents

require 'uuidtools'
module Rhosync
  class ApiToken < Model
    field :value,:string
    field :user_id,:string
    validates_presence_of :user_id
    
    def self.create(fields)
      fields[:value] = fields[:value] || get_random_uuid
      fields[:id] = fields[:value]
      object = super(fields)
    end
    
    def user
      @user ||= User.load(self.user_id)
    end
  end
end
    

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
rhosync-2.1.6 lib/rhosync/api_token.rb
rhosync-2.1.3 lib/rhosync/api_token.rb
rhosync-2.1.2 lib/rhosync/api_token.rb
rhosync-2.1.1 lib/rhosync/api_token.rb
rhosync-2.1.0 lib/rhosync/api_token.rb
rhosync-2.1.0.beta.2 lib/rhosync/api_token.rb
rhosync-2.1.0.beta.1 lib/rhosync/api_token.rb
rhosync-2.0.9 lib/rhosync/api_token.rb
rhosync-2.0.8 lib/rhosync/api_token.rb
rhosync-2.0.7 lib/rhosync/api_token.rb
rhosync-2.0.6 lib/rhosync/api_token.rb
rhosync-2.0.5 lib/rhosync/api_token.rb
rhosync-2.0.4 lib/rhosync/api_token.rb
rhosync-2.0.3 lib/rhosync/api_token.rb
rhosync-2.0.2 lib/rhosync/api_token.rb
rhosync-2.0.1 lib/rhosync/api_token.rb
rhosync-2.0.0 lib/rhosync/api_token.rb
rhosync-2.0.0.rc2 lib/rhosync/api_token.rb
rhosync-2.0.0.rc1 lib/rhosync/api_token.rb
rhosync-2.0.0.beta13 lib/rhosync/api_token.rb