Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # encoding: UTF-8
- class EventsController < ApplicationController
- before_action :set_client
- before_action :set_resource_and_identifier
- def index
- # Somebody's looking for lectures, ey? Well, let's look too!
- events = @api.events_for @resource, @identifier, params
- # Give the poor guy his lectures
- render json: events, root: false
- end
- private
- def set_client
- # Load the correct API for given client
- @client = Client.find_by_id params[:client_id]
- require_dependency "#{Rails.root}/lib/api/#{@client.api_name}/#{@client.api_name}"
- @api = @client.api_name.capitalize.constantize
- end
- def set_resource_and_identifier
- res, @identifier = request.path.split('/')[3, 4]
- @resource = res.singularize
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement