Skip to content

Commit

Permalink
Refactor. [#70]
Browse files Browse the repository at this point in the history
  • Loading branch information
marnen committed Mar 11, 2018
1 parent bd12c55 commit fec3043
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions phoenix/contraq/lib/contraq/naming.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defmodule Contraq.Naming do
@spec dasherize(String.t) :: String.t
def dasherize(string), do: String.replace string, "_", "-"
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- container! @gig do
%h1.name= link_to @gig
- for field_name <- fields do
- field_class = dasherize(field_name)
- field_class = class_for(field_name)
%div{class: field_class}= field @gig, field_name
.actions= cell ContraqWeb.ButtonCell, model: @gig, action: :edit
6 changes: 3 additions & 3 deletions phoenix/contraq/lib/contraq_web/cells/gig/view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ defmodule ContraqWeb.GigCell do
end
end

@spec dasherize(atom | String.t) :: String.t
defp dasherize(string) do
string |> to_string |> String.replace("_", "-")
@spec class_for(atom | String.t) :: String.t
defp class_for(field_name) do
field_name |> to_string |> Contraq.Naming.dasherize
end

@spec field(%Gig{}, atom) :: String.t
Expand Down

0 comments on commit fec3043

Please sign in to comment.