Skip to content

Commit

Permalink
update for elixir 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
eitoball committed Aug 17, 2014
1 parent 50c2c0d commit ef85cb9
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 26 deletions.
3 changes: 2 additions & 1 deletion lib/atlas/accessors.ex
Expand Up @@ -70,7 +70,8 @@ defmodule Atlas.Accessors do
%User{email: "user@example.com"}
"""
def new(attributes \\ []) when is_list(attributes) do
def new(attributes \\ [])
def new(attributes) when is_list(attributes) do
assign(struct(__MODULE__, attributes), attributes)
end
def new(map) when is_map(map) do
Expand Down
12 changes: 6 additions & 6 deletions lib/atlas/adapters/postgres.ex
Expand Up @@ -6,10 +6,10 @@ defmodule Atlas.Adapters.Postgres do

def connect(config) do
case PG.connect(
List.from_char_data!(config.host),
List.from_char_data!(config.username),
List.from_char_data!(config.password),
database: List.from_char_data!(config.database)) do
String.to_char_list(config.host),
String.to_char_list(config.username),
String.to_char_list(config.password),
database: String.to_char_list(config.database)) do

{:ok, pid} -> {:ok, pid}
{:error, reason} -> {:error, reason}
Expand Down Expand Up @@ -107,12 +107,12 @@ defmodule Atlas.Adapters.Postgres do
# Ex: [{:column,"id",:int4,4,-1,0}, {:column,"age",:int4,4,-1,0}]
# => [:id, :age]
defp normalize_cols(columns) do
Enum.map columns, fn col -> binary_to_atom(elem(col, 1)) end
Enum.map columns, fn col -> String.to_atom(elem(col, 1)) end
end

defp normalize_rows(rows_of_tuples) do
rows_of_tuples
|> Enum.map(&tuple_to_list(&1))
|> Enum.map(&Tuple.to_list(&1))
|> Enum.map(&normalize_values(&1))
end
end
8 changes: 4 additions & 4 deletions lib/atlas/exceptions/adapter_error.ex
@@ -1,8 +1,8 @@
defexception Atlas.Exceptions.AdapterError,
message: "Error when performing query",
can_retry: false do
defmodule Atlas.Exceptions.AdapterError do
defexception [message: "Error when performing query",
can_retry: false]

def full_message(me) do
"Call failed: #{me.message}, retriable: #{me.can_retry}"
end
end
end
8 changes: 4 additions & 4 deletions lib/atlas/exceptions/undefined_relationship.ex
@@ -1,8 +1,8 @@
defexception Atlas.Exceptions.UndefinedRelationship,
message: "Undefined model relationship",
can_retry: false do
defmodule Atlas.Exceptions.UndefinedRelationship do
defexception [message: "Undefined model relationship",
can_retry: false]

def full_message(me) do
"Call failed: #{me.message}, retriable: #{me.can_retry}"
end
end
end
2 changes: 1 addition & 1 deletion lib/atlas/field_converter.ex
Expand Up @@ -29,7 +29,7 @@ defmodule Atlas.FieldConverter do
end

def value_to_field_type(value, :boolean) when is_boolean(value), do: value
def value_to_field_type(value, :boolean), do: binary_to_atom(to_string(value)) == true
def value_to_field_type(value, :boolean), do: String.to_atom(to_string(value)) == true

def value_to_field_type(value, :datetime) when is_binary(value), do: value
def value_to_field_type(nil, :datetime), do: nil
Expand Down
2 changes: 1 addition & 1 deletion lib/atlas/finders.ex
Expand Up @@ -27,7 +27,7 @@ defmodule Atlas.Finders do
quote unquote: false do
Enum.each @fields, fn field ->
field_name = elem(field, 0)
def unquote(binary_to_atom "with_#{field_name}")(value) do
def unquote(String.to_atom "with_#{field_name}")(value) do
where([{unquote(field_name), value}])
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/atlas/protocols/count.ex
Expand Up @@ -12,7 +12,7 @@ end

defimpl Atlas.Count, for: Atom do
def count(nil), do: 0
def count(atom), do: atom |> atom_to_binary |> String.length
def count(atom), do: atom |> Atom.to_string |> String.length
end

defimpl Atlas.Count, for: Map do
Expand Down
3 changes: 2 additions & 1 deletion lib/atlas/query/query.ex
Expand Up @@ -3,7 +3,8 @@ defmodule Atlas.Query do
joins: [], limit: nil, offset: nil, order_by: nil,
order_by_direction: nil, count: false

def new(attributes \\ []) when is_list(attributes) do
def new(attributes \\ [])
def new(attributes) when is_list(attributes) do
struct(__MODULE__, attributes)
end
def new(map) when is_map(map) do
Expand Down
2 changes: 1 addition & 1 deletion lib/atlas/repo.ex
Expand Up @@ -26,7 +26,7 @@ defmodule Atlas.Repo do
The unique identifier of the repo's genserver adapter process
"""
def server_name do
binary_to_atom "repo_server_#{String.downcase(to_string(unquote(__MODULE__)))}"
String.to_atom "repo_server_#{String.downcase(to_string(unquote(__MODULE__)))}"
end

@doc """
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Expand Up @@ -5,7 +5,7 @@ defmodule Atlas.Mixfile do
[
app: :atlas,
version: "0.2.0",
elixir: ">= 0.13.3",
elixir: "~> 0.15.0",
deps: deps,
package: [
contributors: ["Chris McCord", "Sonny Scroggin"],
Expand Down
2 changes: 1 addition & 1 deletion mix.lock
@@ -1 +1 @@
[ "epgsql": {:git,"git://github.com/wg/epgsql.git","3318bd5d646cad0623ae9dcc6df015bb85258a63",[]} ]
%{"epgsql": {:git, "git://github.com/wg/epgsql.git", "3318bd5d646cad0623ae9dcc6df015bb85258a63", []}}
5 changes: 1 addition & 4 deletions test/persistence_test_helper.exs
Expand Up @@ -88,13 +88,10 @@ defmodule Atlas.PersistenceTestHelper do

setup_all do
create_table
on_exit fn -> drop_table end
:ok
end

teardown_all do
drop_table
:ok
end
end
end
end

0 comments on commit ef85cb9

Please sign in to comment.