YtPotion.Resource (yt_potion v1.0.0)

Copy Markdown

Macro for declaring a YouTube Data API resource from a {path, actions} pair, replacing one hand-written module + macro per endpoint.

defmodule YtPotion.Resources.Search do
  use YtPotion.Resource, path: "search", actions: [:list]
end

Only actions present in :actions get a function generated — there is no implicit default, so it's clear at each call site what's enabled. Phase 1 resources only ever pass actions: [:list]; Phase 3 adds :insert, :update, and :delete clauses to action_ast/2 (a new private function clause each, no redesign of this macro) and any resource that lists one of them in :actions picks up the generated function.