Skip to content

Instantly share code, notes, and snippets.

Avatar

Amos King adkron

View GitHub Profile
View gist:23adbc946942b84401af
# From http://blog.boochtek.com/2015/02/23/hexagonal-rails-controllers
class OrderController < ApplicationController
def index
interactor.on(:display) { |orders| render orders }
interactor.list
end
def show
interactor.on(:display) { |order| render order }
View CreditInclusionType::Null.rb
class CreditInclusionType < IDontCare
Null = Object.new
class << Null
def by_term?
false
end
def by_credits?
false
@adkron
adkron / bob.rb
Last active Dec 20, 2015 — forked from anonymous/bob.rb
I edited this in the browser so I might not be quite right, but I think I got it.
View bob.rb
class << Silent = Object.new
def heard?(other)
other.empty?
end
def respond
"Fine. Be that way."
end
end
View associations.rb
module ApiEndpoint
def endpoint_for(id)
id.constantize.eval do
has_many self.underscore, :through => :api_objects, :source => :endpoint, :source_type => self.to_s
end
has_many :api_objects, :as => :endpoint
has_many id, :through => :api_objects
end
end
View gist:104831
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
# Don't load rspec if running "rake gems:*"
unless ARGV.any? {|a| a =~ /^gems/}
begin
require 'spec/rake/spectask'
rescue MissingSourceFile
module Spec
module Rake
View gist:84319
# tokens/termials
EQ
LBRACE
RBRACE
LPAREN
RPAREN
DOT
COMMA
PIPE