• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
A Blink Into The Rails Magic
 

A Blink Into The Rails Magic

on

  • 1,234 views

My presentation at Athens Digital Week '09

My presentation at Athens Digital Week '09

Statistics

Views

Total Views
1,234
Views on SlideShare
1,227
Embed Views
7

Actions

Likes
0
Downloads
4
Comments
0

1 Embed 7

http://www.linkedin.com 7

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    A Blink Into The Rails Magic A Blink Into The Rails Magic Presentation Transcript

    • A blink into the “rails magic”
      The meta-programming in Rails / Rails as a code generator
    • Some rights reserved
      Nikos Dimitrakopoulos, 2009
      http://blog.nikosd.com
    • The “classic” rails ingredients
      MVC
      DRY
      COC

    • Not for today…
      MVC
      DRY
      COC

    • Rails as a code generator
    • PART I : 100% Static
    • The directory structure
    • Models + Tests
    • Controllers / views + tests
    • Resources (the whole set)
    • Even with *implemented* views & controllers (a.k.a. “scaffolds”)
    • Static(*) API
    • Nothing special so far…
    • PART II : 100% On-the-fly
    • This is where the actual fun begins!
    • Some basic stuff: ORM
    • How does Rails map the attributes???
    • The truth is in the source…
    • A blink into the “magic”
    • if we haven’t already generated the “dynamic” methods
    • if we haven’t already generated the “dynamic” methods
      • generate them
    • if we haven’t already generated the “dynamic” methods
      • generate them
      • try to call the method with the given name again!
    • for each column on the db table :
    • for each column on the db table :
      • define a “read” method
    • for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
    • for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
      • define a “write” method
    • for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
      • define a “write” method
      (for example the Guest#name = …)
    • for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
      • define a “write” method
      (for example the Guest#name = …)
      • define a “question” method
    • for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
      • define a “write” method
      (for example the Guest#name = …)
      • define a “question” method
      (for example the Guest#name?)
    • PART III : Magic happens Everywhere
    • On the routes / Controllers
    • + 3 more by default
    • + 3 more by default
      More info on “resources” :
      http://api.rubyonrails.org/classes/ActionController/Resources.html
    • On the ORM / Models
    • Dynamic finders
    • Dynamic finders
    • As said this is just a “blink”
    • Look for more in :
      • ActiveRecordassociations
      • ActiveRecordnamed_scopes
      • ActionControllerroutes
      • ActionControllerrendering
      • ActionControllerformat
      • etc…
    • What do we get from this?
    • What do we get from this?
      • Glue code
    • What do we get from this?
      • Glue code
      • Domain-aware code
    • What do we get from this?
      • Glue code
      • Domain-aware code
      • Out of the box
    • What do we get from this?
      • Glue code
      • Domain-aware code
      • Out of the box
      • Every time
    • What do we get from this?
      • Glue code
      • Domain-aware code
      • Out of the box
      • Every time
      • On every app
    • Compare it with Java or .Net “enterprise” solutions…
    • Compare it with Java or .Net “enterprise” solutions…
      © Rubyrags.com
    • Implement your own!!!
    • Implement your own!!!
      (Jim will give you a hint tomorrow at the Ruby Meetup)
    • Thanks for your time
    • Thanks for your time
      And welcome
      to themagic world of
      Rubyand Ruby on Rails