Skip to content

Instantly share code, notes, and snippets.

@camshaft
Forked from mndvns/resource_cases.ex
Last active February 1, 2016 19:15
Show Gist options
  • Save camshaft/0521134e8f9b7687899a to your computer and use it in GitHub Desktop.
Save camshaft/0521134e8f9b7687899a to your computer and use it in GitHub Desktop.
defmodule Api.Resource.Cases do
use PoeApi.Resource
let service = Resource.param(:service)
let cases = apply(service, :get_all, [Input.get])
hyper do
action do
%{
"count" => length(cases),
"collection" => for item <- cases do
link_to(Resource.param(:read), item: item["sys_id"])
|> ^Map.merge(item)
end,
"create" => link_to(Resource.param(:create))
}
end
end
end
defmodule Router do
get "/change_requests", {Api.Resource.Cases, ChangeRequests}, service: Api.Service.ChangeRequests,
read: {Api.Resource.Cases, ChangeRequests.Read},
create: {Api.Resource.Cases, ChangeRequests.Create}
get "/service_requests", {Api.Resource.Cases, ServiceRequests}, service: Api.Service.ServiceRequests,
read: {Api.Resource.Cases, ServiceRequests.Read},
create: {Api.Resource.Cases, ServiceRequests.Create}
end
@mndvns
Copy link

mndvns commented Feb 1, 2016

λ : make
Erlang/OTP 18 [erts-7.2.1] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]

Compiled lib/api.ex
lib/api/http.ex:1: warning: the underscored variable "_path" is used after being set. A leading underscore indicates that the value of the variable should be ignored. If this is intended please rename the variable to remove the underscore
Compiled lib/api/http.ex
Compiled lib/api/resource/root.ex

== Compilation error on file lib/api/resource/cases.ex ==
** (Protocol.UndefinedError) protocol String.Chars not implemented for Elixir.Mazurka.Resource.Resource.get_param(Elixir.Mazurka.Resource.Resource.resource_params(), :service)
    (elixir) lib/string/chars.ex:3: String.Chars.impl_for!/1
    (elixir) lib/string/chars.ex:17: String.Chars.to_string/1
    lib/etude/utils.ex:98: Etude.Utils.debug_call/4
    lib/etude/node/call.ex:73: Etude.Node.Etude.Node.Call.compile_exec/4
    lib/etude/node/call.ex:59: Etude.Node.Etude.Node.Call.compile/2
    lib/etude/children.ex:11: anonymous fn/3 in Etude.Children.compile/2
    (elixir) lib/enum.ex:1473: Enum."-reduce/3-lists^foldl/2-0-"/3
    lib/etude/node/assign.ex:21: Etude.Node.Etude.Node.Assign.compile/2

make: *** [start] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment