Sha256: 7ea02b501884a1ffc2806bf5d145ed0ee988eb9e0d28edb5eced29586ea231b8
Contents?: true
Size: 900 Bytes
Versions: 48
Compression:
Stored size: 900 Bytes
Contents
class ForestLiana::Router def call(env) params = env['action_dispatch.request.path_parameters'] resource = ForestLiana::SchemaUtils.find_model_from_collection_name(params[:collection]) begin component_prefix = ForestLiana.component_prefix(resource) controller_name = "#{component_prefix}Controller" controller = "ForestLiana::UserSpace::#{controller_name}".constantize action = nil case env['REQUEST_METHOD'] when 'GET' if params[:id] action = 'show' else action = 'index' end when 'PUT' action = 'update' when 'POST' action = 'create' when 'DELETE' action = 'destroy' end controller.action(action.to_sym).call(env) rescue NoMethodError => exception ForestLiana::ApplicationController.action(:route_not_found).call(env) end end end
Version data entries
48 entries across 48 versions & 1 rubygems