Sha256: 49c9215f48a5b1085d3873a71e956926d2563bb7966403817e4c93ee47ac8276
Contents?: true
Size: 759 Bytes
Versions: 3
Compression:
Stored size: 759 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 = 'destroy' 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.18 | app/controllers/forest_liana/router.rb |
forest_liana-1.5.17 | app/controllers/forest_liana/router.rb |
forest_liana-1.5.16 | app/controllers/forest_liana/router.rb |