Sha256: 8dd8821bbd31fe0cf235983ed1d40ef42aec1c2bebe3c22a1607869ddac500c1
Contents?: true
Size: 758 Bytes
Versions: 3
Compression:
Stored size: 758 Bytes
Contents
class ForestLiana::Router def call(env) params = env['action_dispatch.request.path_parameters'] resource = ForestLiana::SchemaUtils.find_model_from_table_name(params[:collection]) class_name = resource.table_name.classify module_name = class_name.deconstantize name = module_name if module_name name += class_name.demodulize ctrl_class = "ForestLiana::#{name}Controller".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 = 'delete' end ctrl_class.action(action.to_sym).call(env) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
forest_liana-1.5.15 | app/controllers/forest_liana/router.rb |
forest_liana-1.5.14 | app/controllers/forest_liana/router.rb |
forest_liana-1.5.13 | app/controllers/forest_liana/router.rb |