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
diff --git a/nectar-web-router.ex b/nectar-web-router.ex | |
index 943ae30..90330bb 100644 | |
--- a/nectar-web-router.ex | |
+++ b/nectar-web-router.ex | |
@@ -1,3 +1,6 @@ | |
+## Library Code | |
+## Defines DSL to be used by Service Code | |
+## in order to get properly consumed by Consume | |
defmodule Nectar.RouterExtension do | |
defmacro __using__(_opts) do |
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
#!/usr/bin/env bash | |
if [[ $# -eq 2 ]] ; then | |
echo "Start Commit: $1\nEnd Commit: $2" | |
else | |
>&2 echo "Usage: DRY_RUN=1 $0 [Start-Commit] [End-Commit]\nExample: $0 d2b931acb891d74014d2c5f6a1996f69c222e01c 5c3b13ad8e0c4cf742adc990593926eb25d36fcd" | |
exit 1 | |
fi | |
echo "Is Dry run ?? $DRY_RUN" |
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
nectarcommerce ~/elixir$ iex -S mix | |
## File Compilation Removed | |
iex(1)> Nectar.Product.fn_from_outside | |
"support function" | |
iex(2)> Nectar.Product.get_name(%Nectar.Product{name: "Name"}) | |
"Name" | |
iex(3)> a = Nectar.Repo.get(Nectar.Product, 1) | |
[debug] SELECT p0."id", p0."name", p0."description", p0."available_on", p0."discontinue_on", p0."slug", p0."inserted_at", p0."updated_at" FROM "products" AS p0 WHERE (p0."id" = $1) [1] OK query=271.8ms queue=31.0ms | |
%Nectar.Product{__meta__: #Ecto.Schema.Metadata<:loaded>, | |
available_on: #Ecto.Date<2016-03-29>, |
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
## Library Code | |
## Defines DSL to be used by Service Code | |
## in order to get properly consumed by Consumer | |
defmodule Nectar.ModelExtension do | |
defmacro __using__(_opts) do | |
quote do | |
Module.register_attribute(__MODULE__, :method_block, accumulate: true) | |
import Nectar.ModelExtension, only: [include_method: 1] | |
@before_compile Nectar.ModelExtension | |
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
nectarcommerce ~/elixir$ iex -S mix phoenix.server | |
## File Compilation Removed | |
iex(1)> Nectar.SessionView.render("from_extension.html") | |
"Please provide an override" |
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 Extensions.ViewExtension do | |
defmacro __using__(_opts) do | |
quote do | |
Module.register_attribute(__MODULE__, :partials, accumulate: true) | |
import Extensions.ViewExtension, only: [provide_partial: 2] | |
@before_compile Extensions.ViewExtension | |
defmacro __using__(_opts) do | |
quote do |
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 ExtendCheckoutView do | |
use Extensions.ViewExtension | |
use NectarWallet.NectarExtension, install: "checkout_view" | |
end |
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 Nectar.Web do | |
def view do | |
quote do | |
use Nectar.Extender # ensure it is first import, since Phoenix.View will create a some methods due to which it will not be matchable | |
... | |
end | |
end | |
end |
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 NectarWallet.NectarExtension do | |
defmacro __using__([install: install_type]) do | |
do_install(install_type) | |
end | |
defp do_install("checkout_view") do | |
quote do | |
provide_partial(NectarWallet.WalletView, "payment.nectar_wallet.html") | |
end | |
end |
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 NectarWallet.WalletView do | |
use Nectar.Web, :view | |
def render("payment.nectar_wallet.html", assigns) do | |
"Pay with my wallet" | |
end | |
end |