shopify icon indicating copy to clipboard operation
shopify copied to clipboard

Remove douplicate code from Resource / NestedResource

Open Ninigi opened this issue 6 years ago • 0 comments

Because we are defining singular_resource, plural_resource and to_json in both modules, linters will warn you about "functions can not match because a previous function will always match"

defmodule Shopify.Variant do
  @derive [Poison.Encoder]
  @singular "variant"
  @plural "variants"

  use Shopify.Resource, import: [
    :find
  ]

  # This will trigger warnings:
  use Shopify.NestedResource, import: [
    :create,
    :all,
    :count,
    :update,
    :delete
  ]
  # ...
end

One way to solve this would be to move to_json and the resource functions in respective modules.

Ninigi avatar Mar 14 '18 01:03 Ninigi