Sha256: 566c73c7e716e204a91a66e5868a57eca2064a3bd34c6bf249783073e00bd18e

Contents?: true

Size: 1.04 KB

Versions: 32

Compression:

Stored size: 1.04 KB

Contents

module Endpoints
  class <%= plural_class_name %> < Base
    namespace "<%= url_path %>" do
      serializer Serializers::<%= singular_class_name %>


      get do
        encode serialize(<%= singular_class_name %>.all)
      end

      post do
        # warning: not safe
        <%= field_name %> = <%= singular_class_name %>.new(body_params)
        <%= field_name %>.save
        status 201
        encode serialize(<%= field_name %>)
      end

      get "/:id" do |id|
        <%= field_name %> = <%= singular_class_name %>.first(id: id) || halt(404)
        encode serialize(<%= field_name %>)
      end

      patch "/:id" do |id|
        <%= field_name %> = <%= singular_class_name %>.first(id: id) || halt(404)
        # warning: not safe
        #<%= field_name %>.update(body_params)
        encode serialize(<%= field_name %>)
      end

      delete "/:id" do |id|
        <%= field_name %> = <%= singular_class_name %>.first(id: id) || halt(404)
        <%= field_name %>.destroy
        encode serialize(<%= field_name %>)
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
pliny-1.1.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-1.0.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.32.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.31.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.30.1 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.30.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.29.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.28.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.27.1 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.27.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.26.2 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.26.1 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.26.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.25.1 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.25.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.24.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.23.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.22.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.21.0 lib/pliny/templates/endpoint_scaffold.erb
pliny-0.20.2 lib/pliny/templates/endpoint_scaffold.erb