-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Readme appears wrong and api won't initialize #21
Comments
Also, is if it helps, we're on Erlang 21 and Elixir 1.8.1 |
Could you post the stacktrace? You're not misunderstanding the API, and you shouldn't have to |
@newtrat Thanks! Here's the stack trace. Sorry -- I should have included this initially!
|
Sorry, I haven't been able to reproduce this bug yet. This is a long shot, but perhaps try clearing and reinstalling your dependencies with Here is some relevant code from Poison, version 3.1.0, as stored in my I've included only the clauses that I think are actually getting called... though I could be wrong 🙂 defmodule Poison.Decode do
def decode(value, options) when is_map(value) or is_list(value) do
case options[:as] do
nil -> value
as -> transform(value, options[:keys], as, options)
end
end
defp transform(value, keys, %{__struct__: _} = as, options) do
transform_struct(value, keys, as, options)
end
defp transform_struct(value, keys, as, options) when keys in [:atoms, :atoms!] do
as
|> Map.from_struct
|> Map.merge(value)
|> do_transform_struct(keys, as, options)
end
defp do_transform_struct(value, keys, as, options) do
default = struct(as.__struct__)
as
|> Map.from_struct
|> Enum.reduce(%{}, fn {key, as}, acc ->
new_value = case Map.fetch(value, key) do
{:ok, ^as} when is_map(as) or is_list(as) ->
Map.get(default, key)
{:ok, value} when is_map(value) or is_list(value) ->
transform(value, keys, as, options)
{:ok, value} ->
value
:error ->
Map.get(default, key)
end
Map.put(acc, key, new_value)
end)
|> Map.put(:__struct__, as.__struct__)
|> Poison.Decoder.decode(options)
end
What we're passing into Can you check out your |
Hi!
Thanks for creating this! I'm trying to get it working and am running into some issues.
First, there is not Prismic.V2.API. That commit to the README happened early in the life of the project and, as far as I can tell, there has never been a Prismic.V2 module.
Second, when I try to init the api (or do Prismic.all), I get this:
I've added
defimpl Enumerable, for: Prismic.Ref do ...
anddefimpl Enumerable, for: Prismic.API do...
and then I just get** (UndefinedFunctionError) function nil.__struct__/0 is undefined. If you are using the dot syntax, such as map.field or module.function, make sure the left side of the dot is an atom or a map
.Am I'm just grossly misunderstanding the API? Let me know!
The text was updated successfully, but these errors were encountered: