Created
July 19, 2017 16:12
-
-
Save pmarreck/27f6ea5d937904f553d90568fb306d2e to your computer and use it in GitHub Desktop.
trying to use ecto_enum...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Mpnetwork.EnumMaps do | |
import EctoEnum | |
# Housing Class Types | |
@class_types_int ~w[residential condo co_op hoa rental land com_ind]a | |
def class_types_int, do: @class_types_int | |
@class_types_ext ~w[Residential Condo Co-op HOA Rental Land Commercial/Industrial] | |
# def class_types_ext, do: @class_types_ext | |
@class_types_int_to_ext_map Enum.zip(@class_types_int, @class_types_ext) |> Map.new | |
@class_types_ext_to_int_map Enum.zip(@class_types_ext, @class_types_int) |> Map.new | |
def map_class_type_int_to_ext(k) when is_atom(k), do: @class_types_int_to_ext_map[k] | |
def map_class_type_int_to_ext(k) when is_binary(k), do: @class_types_int_to_ext_map[String.to_existing_atom(k)] | |
def map_class_type_ext_to_int(k) when is_binary(k), do: @class_types_ext_to_int_map[k] | |
defenum ClassTypeEnum, :class_type, @class_types_int | |
# ... | |
end |
Author
pmarreck
commented
Jul 19, 2017
@pmarreck what if you change https://github.com/blackswan-ventures/events/pull/19 to:
defenum ClassTypeEnum, :class_type, ~w[residential condo co_op hoa rental land com_ind]a
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment