Skip to content

Instantly share code, notes, and snippets.

# This is modified version of https://github.com/infinitered/phoenix_base/blob/master/lib/phoenix_base/maybe.ex
#
# Discussion https://elixirforum.com/t/maybe-nil-protection-for-nested-structs/468/8
# The reason behind adding maybe https://elixirforum.com/t/elixir-version-of-a-safe-navigation-operator-navigating-nil-in-maps-structs/6023/7
# Why Access Protocol is not implemented for struct: https://github.com/elixir-lang/elixir/issues/2973
#
defmodule Streamgard.Utils.Maybe do
@moduledoc """
## Example
import Maybe
for f in `find . -name 'Main-picture'`; do mv -v "$f" "`echo $f | tr '[A-Z]' '[a-z]'`"; done
# Store level
class ApplicationController
class FeatureException < StandardError; end
rescue_from FeatureException do |err|
redirect_to website_dashboard_path, alert: err.message
end
def authorize_feature!(name)
@ndan
ndan / estimate_index_page.rb
Last active December 5, 2016 12:11
page objects
# support/pages/organization_pages/estimate_index_page.rb:21
require_relative '../page_object'
module OrganizationPages
class EstimateIndexPage < PageObject
def self.visit(subdomain)
navigate '/estimates', subdomain: subdomain
new
end
module A
hello = proc { self }
define_method :method do
puts hello.call
end
# def self.included(base)
# this = self
# base.instance_eval do