I hereby claim:
- I am dnagir on github.
- I am dnagir (https://keybase.io/dnagir) on keybase.
- I have a public key ASBRKxPaRBzw3Jtnf172oWrOYt26nFkIkKk1fQBviIFkHwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
require 'dry/validation' | |
require 'dry/types' | |
require 'dry/struct' | |
module Types | |
include Dry::Types() | |
end | |
class OrderContract < Dry::Validation::Contract | |
params do |
require 'bundler/inline' | |
gemfile do | |
gem 'dry-validation', '=1.0.0.rc1' | |
gem 'dry-transaction', '=0.13.0' | |
gem 'minitest', '=5.11.3' | |
end | |
require 'dry-validation' | |
require 'dry/transaction' |
require 'singleton' | |
module Maybe | |
class Just < BasicObject | |
attr_reader :value | |
def initialize(value) | |
@value = value | |
end |
gem 'activerecord', '4.2.5' | |
require 'active_record' | |
require 'minitest/autorun' | |
require 'logger' | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'postgresql', | |
:database => 'x' | |
) |
module ApplicationHelper | |
def with_variant(new_variant, &block) | |
old_variants = lookup_context.variants | |
begin | |
lookup_context.variants = [new_variant] | |
return block.call | |
ensure | |
lookup_context.variants = old_variants | |
end | |
end |
> ruby -v | |
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0] | |
> ruby test.rb | |
Run options: --seed 22679 | |
# Running: | |
F. | |
Finished in 2.320485s, 0.8619 runs/s, 172.3778 assertions/s. |
> rvm use ruby-2.1.1 | |
Using /Users/dnagir/.rvm/gems/ruby-2.1.1 | |
> ruby -v | |
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0] | |
> ruby test.rb | |
Run options: --seed 49028 | |
# Running: |
# In the context of Rails app (mailers) | |
# Somewhere in email helper | |
def from_address_by(person_name) | |
return nil unless person_name | |
address = Mail::Address.new AppConfig.email.from # ex: "[email protected]" | |
address.display_name = person_name # ex: "John Doe" | |
address.format # returns "John Doe <[email protected]>" | |
end |