Class: ApiKey

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/api_key.rb

Overview

COPYRIGHT:

Copyright (c) 2005-2010 North Carolina State University
Developed with funding for the National eXtension Initiative.

LICENSE:

BSD(-compatible)
see LICENSE file or view at http://about.extension.org/wiki/LICENSE

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) systemkey



28
29
30
# File 'app/models/api_key.rb', line 28

def self.systemkey
  find(1)
end

Instance Method Details

- (Object) generate_keyvalue



15
16
17
18
# File 'app/models/api_key.rb', line 15

def generate_keyvalue
  randval = rand
  self.keyvalue = Digest::SHA1.hexdigest(AppConfig.configtable['sessionsecret']+self.user_id.to_s+self.name+randval.to_s)
end

- (Object) today_usage



24
25
26
# File 'app/models/api_key.rb', line 24

def today_usage
  self.api_key_events.count(:all, :conditions => "DATE(created_at) = DATE(NOW())")
end

- (Object) total_usage



20
21
22
# File 'app/models/api_key.rb', line 20

def total_usage
  self.api_key_events.count
end