Module: OAuth2::Provider::Models::Authorization::ClassMethods

Defined in:
lib/oauth2/provider/models/authorization.rb

Instance Method Summary collapse

Instance Method Details

#all_for(ro) ⇒ Object


44
45
46
47
# File 'lib/oauth2/provider/models/authorization.rb', line 44

def all_for(ro)
  return [] unless ro
  self.where(:resource_owner_id => ro.id, :resource_owner_type => ro.class.name).all
end

#allowing(client, owner, scope) ⇒ Object


35
36
37
38
39
40
41
42
# File 'lib/oauth2/provider/models/authorization.rb', line 35

def allowing(client, owner, scope)
  where(
    :client_id => client.id,
    :resource_owner_id => owner && owner.id,
    :resource_owner_type => owner && owner.class.name,
    :scope => scope
  ).select(&:fresh?)
end