Class: Oauth2Provider::OauthDailyRequest

Inherits:
Object
  • Object
show all
Includes:
Mongoid::Document
Defined in:
app/models/oauth2_provider/oauth_daily_request.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_day(time) ⇒ Object

Find a daily requests record



31
32
33
34
# File 'app/models/oauth2_provider/oauth_daily_request.rb', line 31

def find_day(time)
  time_id = time_id(time)
  where(time_id: time_id)
end

.time_id(time) ⇒ Object

Define an identifier for a specific day



37
38
39
# File 'app/models/oauth2_provider/oauth_daily_request.rb', line 37

def time_id(time)
  time.strftime("%Y%m%d")
end

Instance Method Details

#increment!Object

Increment the times counter that track the number of requests a client have made in behalf of a resource owner in a specific day



23
24
25
26
# File 'app/models/oauth2_provider/oauth_daily_request.rb', line 23

def increment!
  self.times += 1
  self.save
end