Skip to content

Instantly share code, notes, and snippets.

View joeletizia's full-sized avatar

Joe Letizia joeletizia

View GitHub Profile
@joeletizia
joeletizia / products.rb
Created December 15, 2015 22:21
Controller resources that are agnostic of content type to be rendered.
module Products
# What if we want to differ the content between iOS and Web?
class IndexResource
def initialize(product_presenters, content_type)
@product_presenters = product_presenters
@content_type = content_type
end
def render(rendering_engine = RenderingEngine)
rendering_engine.render(partial_path, product_presenters: product_presenters)
Dir.glob("**/*.rb").each do |file|
`vim -c "set ts=4 sts=4 noet|retab!|set ts=2 sts=2 et|retab|wq" #{file}`
end
defmodule EmailValidation do
def validate(email) do
email_validation_result = {:ok, email}
check_for_validity(email_validation_result)
|> check_if_email_taken
end
defp check_for_validity({:ok, email}) do
case check_against_regex(email) do
defmodule Success do
@type t :: %Success{value: any}
defstruct value: nil
end
defmodule Failure do
@type t :: %Failure{value: any, reason: String.t}
defstruct value: nil, reason: nil
end