Skip to content

Instantly share code, notes, and snippets.

View therabidbanana's full-sized avatar
🌴
On vacation

David Haslem therabidbanana

🌴
On vacation
  • Pathstream
  • San Francisco
View GitHub Profile
@therabidbanana
therabidbanana / application_controller.rb
Created July 11, 2012 14:41 — forked from gmoeck/some_controller.rb
Simplified version of the application design I'm heading toward (actually in Sinatra, but that doesn't really matter here)
class ApplicationController
# Sharing the setup of processors, since many actions will use them
# - thinking of switching this out for a facade
def trigger_processor(name, listening_controller)
processor_klass = processors[name]
processor = processor_klass.new(params)
processor.add_listener(EventNotifier.new)
processor.add_listener(listening_controller)
processor.process(current_user)
end
@therabidbanana
therabidbanana / README.txt
Created March 14, 2012 14:08 — forked from mikekelly/0_README.txt
A potential new version of hal
I've been playing with the idea of combining the data array defined in application/collection+json
(http://amundsen.com/media-types/collection/format/) with hal links for templated data.
Seems like a good way to keep the media type lightweight while allowing the api to specify the fields
it would like passed to a given resource.
I haven't really given much thought to an xml variation, but I took a stab at it as well.
@therabidbanana
therabidbanana / gist:1041444
Created June 22, 2011 22:39 — forked from jergason/gist:1041434
Two has-and-belongs-to-many Properties to the same model
class Comparison
include DataMapper::Resource
property :id, Serial
has n, :msruns, :through => Resource
has n, :secondary_msruns, "Msrun", :through => SecondaryMsrunComparison, :via => :msrun
belongs_to :metric
end
class Msrun