I hereby claim:
- I am mattbeedle on github.
- I am mattbeedle (https://keybase.io/mattbeedle) on keybase.
- I have a public key whose fingerprint is F463 5667 D1A8 320F EF77 4E74 D15A 6818 9C39 D501
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| class API:V1::Companies | |
| helpers do | |
| def create_company_runner | |
| CreateCompanyRunner.new(create_response, current_user, params[:company]) | |
| end | |
| def create_response | |
| CreateResponse.new(self) | |
| end | |
| end |
| # Here's my experimentation so far with DDD and hexagonal architecture from the past few weeks. | |
| # Code all written straight into this gist so probably full of typos and bugs. | |
| # App consists of controllers, use_cases, policies, responses, services, forms, repositories, adapters, errors. | |
| # Everything can be unit tested and mocked using bogus (https://www.relishapp.com/bogus/bogus/v/0-1-5/docs) | |
| # Controllers can be tested with Rack::Test to ensure they run authetication and call the correct use case. | |
| # All business logic is isolated from the delivery mechanism (grape) so that the delivery mechanism could | |
| # be switched out. | |
| # It would be easy for example to switch to Torqubox and JRuby to take advantage of the massive | |
| # 10000 req/s performance (http://www.madebymarket.com/blog/dev/ruby-web-benchmark-report.html) compared | |
| # to the slowness of Grape. |
| # strong_params version, with business logic tied to controller. | |
| class Something | |
| validates :name, :age, :miles_travelled, presence: true | |
| validates :age, :miles_travelled, :coffee_consumed, :children_eaten, | |
| numericality: { allow_blank: true } | |
| end | |
| class SomethingController < ApplicationController::Base | |
| respond_to :html | |
| # This is a little ember easyform hack to make errors display when the form is | |
| # submitted | |
| Ember.EasyForm.Input.reopen | |
| errorsChanged: (-> | |
| @set('hasFocusedOut', true) | |
| @showValidationError() | |
| ) | |
| didInsertElement: -> | |
| @addObserver("context.errors.#{@property}.@each", @, 'errorsChanged') |
| #!/usr/bin/env bash | |
| echo "Running: heroku pgbackups:capture --remote production" | |
| heroku pgbackups:capture --remote production | |
| echo "curl'ing the latest.dump" | |
| curl -o latest.dump `heroku pgbackups:url --remote production` | |
| echo "restoring the dump" | |
| pg_restore --verbose --clean --no-acl --no-owner -h localhost -U postgres -d project_name_development latest.dump |
| Devise::ConfirmationsController.class_eval do | |
| param_accessible user: [ :email ], only: [ :create ] | |
| end | |
| Devise::PasswordsController.class_eval do | |
| param_accessible user: [ :email ], only: [ :create ] | |
| param_accessible :reset_password_token, only: [ :edit ] | |
| param_accessible user: [ |
| module MultiParameterAttributes | |
| def attributes=(attrs) | |
| multi_parameter_attributes = [] | |
| attrs.each do |name, value| | |
| return if attrs.blank? | |
| if name.to_s.include?("(") | |
| multi_parameter_attributes << [ name, value ] | |
| else | |
| writer_method = "#{name}=" | |
| if respond_to?(writer_method) |
| module Pickle | |
| class Config | |
| def predicates | |
| @predicates ||= Pickle::Adapter.model_classes.map do |k| | |
| k.public_instance_methods.select{|m| m =~ /\?$/} + k.fields.map(&:first) | |
| end.flatten.uniq | |
| end | |
| end | |
| class Adapter |
| module Pickle | |
| class Config | |
| def predicates | |
| @predicates ||= Pickle::Adapter.model_classes.map do |k| | |
| k.public_instance_methods.select{|m| m =~ /\?$/} + k.fields.map(&:first) | |
| end.flatten.uniq | |
| end | |
| end | |
| class Adapter |