Class: TentD::API::Followings::GetMany

Inherits:
Middleware
  • Object
show all
Defined in:
lib/tentd/api/followings.rb

Instance Method Summary collapse

Methods inherited from Middleware

#call, #initialize

Methods included from Authorizable

#authorize_env!, #authorize_env?

Constructor Details

This class inherits a constructor from TentD::API::Middleware

Instance Method Details

#action(env) ⇒ Object



56
57
58
59
60
61
62
63
# File 'lib/tentd/api/followings.rb', line 56

def action(env)
  if authorize_env?(env, :read_followings)
    env.response = Model::Following.fetch_all(env.params) { |p,q,b| q << 'followings.confirmed = true' }
  else
    env.response = Model::Following.fetch_with_permissions(env.params, env.current_auth) { |p,q,b| q << 'AND followings.confirmed = true' }
  end
  env
end