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

D79fc498d7a5b2ce12180890247476f0?s=47 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.

D79fc498d7a5b2ce12180890247476f0?s=128

Jon Rowe

December 11, 2012
Tweet

Transcript

  1. 9.
  2. 13.
  3. 17.

    HEXAGONAL Decouple the application Make the business logic the focus

    Provide adaptors for technology Provide adaptors for I/O
  4. 21.

    HEXAGONAL RAILS Describes structure of application but... Rails is not

    the application ... Rails is the HTTP Adaptor
  5. 22.

    HEXAGONAL RAILS Describes structure of application but... Rails is not

    the application ... Rails is the HTTP Adaptor Describes building apps *with* Rails
  6. 25.
  7. 29.
  8. 33.
  9. 43.
  10. 44.
  11. 47.

    Rails The router is top of the Rails stack Push

    inwards from there Without an addition to the framework?
  12. 48.

    Rails The router is top of the Rails stack Push

    inwards from there Without an addition to the framework?
  13. 49.

    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
  14. 52.
  15. 53.

    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
  16. 54.

    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
  17. 55.