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 Sample.EventHandler do | |
alias KaufmannEx.Schemas.Event | |
def given_event(%Event{name: :"command.user.create", payload: payload} = event) do | |
{:ok, user_info} = Sample.User.create(payload) | |
Publisher.publish(:"event.user.create", user_info, event.meta) | |
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 Sample.EventHandler do | |
alias KaufmannEx.Schemas.Event | |
def given_event(%Event{name: :"command.user.create", payload: payload} = event) do | |
{:ok, user_info} = Sample.User.create(payload) | |
Publisher.publish(:"event.user.create", user_info, event.meta) | |
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 Sample.Publisher do | |
def publish(event_name, payload, context \\ %{}, topic \\ :default) do | |
message_body = %{ | |
payload: payload, | |
meta: event_metadata(event_name, context) | |
} | |
KaufmannEx.Publisher.publish(event_name, message_body, context) |
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 Sample.EventHandlerTest do | |
use KaufmannEx.TestSupport.MockBus | |
test "Events Can Be published & observed" do | |
given_event(:"command.user.create", %{user_name: "Test User", user_email: "[email protected]"}) | |
assert %{ | |
payload: %{user_id: uknown_id} | |
} = then_event(:"event.test") | |
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
module FormHelper | |
class ActionView::Helpers::FormBuilder | |
include ActionView::Helpers::FormTagHelper | |
include ActionView::Helpers::FormOptionsHelper | |
def switch(name, options = {}) | |
@switch_id = "#{@object_name}_#{name}" | |
lbl(name,options) + container(name,options) | |
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
# simple navigation componenent like on iOS | |
# put at the top of your file | |
class Paging | |
pages = Array() | |
constructor: (@bg_layer) -> | |
# push a new page on top |