Skip to content

Instantly share code, notes, and snippets.

View donbonifacio's full-sized avatar
🚀
Building platforms

Pedro Pereira Santos donbonifacio

🚀
Building platforms
View GitHub Profile
(defn gateway-fn
"Retrieves a function given it's full name"
[gateway access method]
{:post [(not (nil? %))]}
(let [sym (symbol (str "project-namespace." (name gateway) "." (name access) "/" (name method)))]
(resolve sym)))
(defn gateway-call
"Dispatches to a function on the given provider"
[access method & args]
@donbonifacio
donbonifacio / gist:560ffc4afa6b3a883d5d
Created April 17, 2015 09:38
Common gateway usage
(defn save!
"Persists an account"
[account]
(common/gateway-call :account-gateway :save! account))
(defn find-by-id
"Find account by given id"
[id]
(common/gateway-call :account-gateway :find-by-id id))
<?xml version="1.0" encoding="UTF-8"?>
<shipping>
<date>19/12/2013</date>
<due_date>19/12/2013</due_date>
<loaded_at>10/10/2050</loaded_at>
<license_plate>00-AA-11</license_plate>
<client>
<name>Joao</name>
<code>Jony123</code>
<email>[email protected]</email>
class Updater
def self.update_total_points(employee)
employee.total_points = employee.rocket_actions.sum(:points)
gateway.persist_employee_total(employee)
end
def gateway
if defined? Rails
rails gateway
//top of steps file or in seperate factory file
require 'factory_girl'
Factory.define :user do |u|
u.login 'the_login'
u.email '[email protected]'
u.password 'password'
u.password_confirmation 'password'
# u.activated_at 'active'
end