Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Abusing The Router (For Hexagonal Fun) - RoRoSy...

Jon Rowe
December 11, 2012

Abusing The Router (For Hexagonal Fun) - RoRoSyd December 12

A short overview of the Hexagonal Architecture style with some fun usages of the router to help us out.

Jon Rowe

December 11, 2012
Tweet

More Decks by Jon Rowe

Other Decks in Programming

Transcript

  1. HEXAGONAL Decouple the application Make the business logic the focus

    Provide adaptors for technology Provide adaptors for I/O
  2. HEXAGONAL RAILS Describes structure of application but... Rails is not

    the application ... Rails is the HTTP Adaptor
  3. HEXAGONAL RAILS Describes structure of application but... Rails is not

    the application ... Rails is the HTTP Adaptor Describes building apps *with* Rails
  4. Rails The router is top of the Rails stack Push

    inwards from there Without an addition to the framework?
  5. Rails The router is top of the Rails stack Push

    inwards from there Without an addition to the framework?
  6. resources :one, controller: :generic, type: One resources :two, controller: :generic,

    type: Two controller GenericController def show params[:type].find params[:id] end #snip... end Router
  7. Constraints class IsAdmin def self.matches? request request.env[‘warden.env’].user!.is_admin? end end class

    IsUser def self.matches? request request.env[‘warden.env’].user! end end
  8. Constraints constraint AllowedAccess.new(:beta) do resource :shiney_thing end class AllowedAccess <

    Struct.new(:feature) attr_reader :feature def matches? request unless Features.new(user).allow? feature throw :warden, Warden::Redirect... end end end