SlideShare una empresa de Scribd logo
1 de 22
Descargar para leer sin conexión
RAILTIES
                                  OU


              COMO DESENVOLVER
            PLUGINS/GEMS PARA RAILS


    Carlos Antonio       blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
$ WHOAMI




    Carlos Antonio        blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
CARLOS ANTONIO DA SILVA

                         @cantoniodasilva


    Carlos Antonio           blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
BSI NA UNIDAVI - RIO DO SUL

      GP NO SENAC - RIO DO SUL/
           FLORIANÓPOLIS


    Carlos Antonio       blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
TRABALHO NA




    Carlos Antonio         blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
DEVISE




    Carlos Antonio       blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
SIMPLE_FORM




    Carlos Antonio         blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
RESPONDERS




    Carlos Antonio         blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
Railties

?

        Carlos Antonio       blog.plataformatec.com.br   @cantoniodasilva
    Sunday, November 6, 11
Railties

?
                                         WTF???
        Carlos Antonio       blog.plataformatec.com.br   @cantoniodasilva
    Sunday, November 6, 11
Initialization




           Application       Railties                    Engine

?
                               Generators


        Carlos Antonio       blog.plataformatec.com.br   @cantoniodasilva
    Sunday, November 6, 11
Initialization




?      HOOKS
           Application       Railties                    Engine




                               Generators


        Carlos Antonio       blog.plataformatec.com.br   @cantoniodasilva
    Sunday, November 6, 11
Railties GENERATORS Hooks

             module FooBar
               class Railtie < Rails::Railtie

                        config.generators.orm = :foo_bar

?              end
             end




        Carlos Antonio                 blog.plataformatec.com.br   @cantoniodasilva
    Sunday, November 6, 11
Railties                   RAKE TASKS                     Hooks
             module FooBar
               class Railtie < Rails::Railtie

                        rake_tasks do
                          load 'foo_bar/foo.rake'

?              end
                        end


             end




        Carlos Antonio                 blog.plataformatec.com.br    @cantoniodasilva
    Sunday, November 6, 11
Railties                            INIT                  Hooks
             module FooBar
               class Railtie < Rails::Railtie

                        # initialization hooks
                        config.before_configuration {}
                        config.before_eager_load {}


?
                        config.before_initialize {}
                        config.after_initialize {}
                        config.to_prepare {}

               end
             end



        Carlos Antonio                 blog.plataformatec.com.br    @cantoniodasilva
    Sunday, November 6, 11
Railties                            INIT                  Hooks
             module FooBar
               class Railtie < Rails::Railtie

                        initializer 'foo_bar.do_whatever' do |app|
                          puts "I'm initializing!"


?
                          # load your stuff here
                        end

               end
             end




        Carlos Antonio                 blog.plataformatec.com.br    @cantoniodasilva
    Sunday, November 6, 11
FRAMEWORK LOADING


                             ActiveSupport.on_load(:active_record) do
                               include FooBar::ActiveRecordExtensions
                             end

?

        Carlos Antonio                    blog.plataformatec.com.br   @cantoniodasilva
    Sunday, November 6, 11
E O QUE EU FAÇO COM
                      ESSE NEGÓCIO DE
                   FRAMEWORK LOADING?



    Carlos Antonio       blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
Railties                            INIT                  Hooks
             module FooBar
               class Railtie < Rails::Railtie

                        initializer 'foo_bar.do_whatever' do |app|
                          ActiveSupport.on_load(:active_record) do


?
                            include FooBar::ActiveRecordExtensions
                          end
                        end

               end
             end



        Carlos Antonio                 blog.plataformatec.com.br    @cantoniodasilva
    Sunday, November 6, 11
EXEMPLO REAL???




    Carlos Antonio           blog.plataformatec.com.br   @cantoniodasilva
Sunday, November 6, 11
module Responders
          autoload :FlashResponder,      'responders/flash_responder'
          autoload :HttpCacheResponder, 'responders/http_cache_responder'
          autoload :CollectionResponder, 'responders/collection_responder'

            require 'responders/controller_method'

            class Railtie < ::Rails::Railtie
              config.responders = ActiveSupport::OrderedOptions.new
              config.generators.scaffold_controller = :responders_controller

                # Add load paths straight to I18n, so engines and application can overwrite it.
                require 'active_support/i18n'
                I18n.load_path << File.expand_path('../responders/locales/en.yml', __FILE__)



?           initializer "responders.flash_responder" do |app|
              if app.config.responders.flash_keys
                Responders::FlashResponder.flash_keys = app.config.responders.flash_keys
              end
            end
          end
        end




        Carlos Antonio                    blog.plataformatec.com.br              @cantoniodasilva
    Sunday, November 6, 11
@cantoniodasilva
                         ?!       blog.plataformatec.com.br



                              Obrigado
                                     !


Sunday, November 6, 11

Más contenido relacionado

Último

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 

Último (20)

Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 

Destacado

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destacado (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

railties @ encontro guru sc (nao apresentado) - 2010.09.18

  • 1. RAILTIES OU COMO DESENVOLVER PLUGINS/GEMS PARA RAILS Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 2. $ WHOAMI Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 3. CARLOS ANTONIO DA SILVA @cantoniodasilva Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 4. BSI NA UNIDAVI - RIO DO SUL GP NO SENAC - RIO DO SUL/ FLORIANÓPOLIS Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 5. TRABALHO NA Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 6. DEVISE Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 7. SIMPLE_FORM Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 8. RESPONDERS Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 9. Railties ? Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 10. Railties ? WTF??? Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 11. Initialization Application Railties Engine ? Generators Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 12. Initialization ? HOOKS Application Railties Engine Generators Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 13. Railties GENERATORS Hooks module FooBar class Railtie < Rails::Railtie config.generators.orm = :foo_bar ? end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 14. Railties RAKE TASKS Hooks module FooBar class Railtie < Rails::Railtie rake_tasks do load 'foo_bar/foo.rake' ? end end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 15. Railties INIT Hooks module FooBar class Railtie < Rails::Railtie # initialization hooks config.before_configuration {} config.before_eager_load {} ? config.before_initialize {} config.after_initialize {} config.to_prepare {} end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 16. Railties INIT Hooks module FooBar class Railtie < Rails::Railtie initializer 'foo_bar.do_whatever' do |app| puts "I'm initializing!" ? # load your stuff here end end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 17. FRAMEWORK LOADING ActiveSupport.on_load(:active_record) do include FooBar::ActiveRecordExtensions end ? Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 18. E O QUE EU FAÇO COM ESSE NEGÓCIO DE FRAMEWORK LOADING? Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 19. Railties INIT Hooks module FooBar class Railtie < Rails::Railtie initializer 'foo_bar.do_whatever' do |app| ActiveSupport.on_load(:active_record) do ? include FooBar::ActiveRecordExtensions end end end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 20. EXEMPLO REAL??? Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 21. module Responders autoload :FlashResponder, 'responders/flash_responder' autoload :HttpCacheResponder, 'responders/http_cache_responder' autoload :CollectionResponder, 'responders/collection_responder' require 'responders/controller_method' class Railtie < ::Rails::Railtie config.responders = ActiveSupport::OrderedOptions.new config.generators.scaffold_controller = :responders_controller # Add load paths straight to I18n, so engines and application can overwrite it. require 'active_support/i18n' I18n.load_path << File.expand_path('../responders/locales/en.yml', __FILE__) ? initializer "responders.flash_responder" do |app| if app.config.responders.flash_keys Responders::FlashResponder.flash_keys = app.config.responders.flash_keys end end end end Carlos Antonio blog.plataformatec.com.br @cantoniodasilva Sunday, November 6, 11
  • 22. @cantoniodasilva ?! blog.plataformatec.com.br Obrigado ! Sunday, November 6, 11