Skip to content

Instantly share code, notes, and snippets.

View adkron's full-sized avatar

Amos King adkron

View GitHub Profile
# 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 }
class CreditInclusionType < IDontCare
Null = Object.new
class << Null
def by_term?
false
end
def by_credits?
false
@adkron
adkron / bob.rb
Last active December 20, 2015 14:39 — forked from anonymous/bob.rb
I edited this in the browser so I might not be quite right, but I think I got it.
class << Silent = Object.new
def heard?(other)
other.empty?
end
def respond
"Fine. Be that way."
end
end
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
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
# tokens/termials
EQ
LBRACE
RBRACE
LPAREN
RPAREN
DOT
COMMA
PIPE