SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
A story about Gemified Engines
A 45-minute introduction to Engines
FYI
A few essential concepts
A few essential concepts
○ A Ruby Gem is a container for reusable
Ruby code.
○ A Rails Gem is a Ruby Gem that depends
on Rails.
○ To "gemify" something, is to create a Gem
out of a piece of isolated Ruby code.
Enlighten me!
Quick intro to Railties & Engines
Quick intro to Railties & Engines
○ Since version 3, Rails major components
are built on top of a core class called
Railtie.
○ Thus, all (new and old) components based
on this class were dubbed "Railties".
○ This class "provides several hooks to
extend Rails and/or modify the
initialization process".1
[1] Taken from http://api.rubyonrails.org/classes/Rails/Railtie.html
Quick intro to Railties & Engines
○ Railties are responsible for their own
initialization/configuration process, making
Rails core's independent from them -sort
of a "plug & play" standard.
○ Obviously, we can create our own Railties
and extend our application, much like any
Rails Gem we know does.
Quick intro to Railties & Engines
○ Read more about Railties:
○ Rails::Railtie - Ruby On Rails API Online
http://api.rubyonrails.org/classes/Rails/Railtie.html
Quick intro to Railties & Engines
○ An Engine is a Railtie.
○ Hence, an Engine can do all that that a
Railtie can do, and more.
○ Internally, Engine inherits from Railtie, as
you imagined.
Quick intro to Railties & Engines
○ Engines are self-contained Rails
applications.
○ Any Rails ~> 3 application is an Engine.
○ Engines you plug into your application
integrate seamlessly adding their
controllers, models, views, routes, etc. as if
they were part of the whole thing.
○ They can also be isolated (namespaced) to
avoid conflicts with the main application.
And...?
Deeper into Engines
Deeper into Engines
○ Engines are the way to extend any Rails 3
application by default.
○ They can be thought of as Plugins (sort of).
○ In fact, the Rails default generator for
Engines is: rails plugin new <name> --
<type>.
○ Type can be full or mountable.
Deeper into Engines
○ Mountable Engines
○ Namespace isolated by default.
○ Meaning: no name-clash conflicts with the "host"
application.
○ All your controllers, models and routes get
isolated inside the namespace.
○ The routes namespace name is defined when
mounting the Engine routes in the routes.rb file.
○ This is a conservative approach.
Deeper into Engines
○ Full Engines
○ No namespace isolation; everything you put in it
will become available to the host application "as
is".
○ Useful if you're adding functionality to existing
resources.
○ Because routes are also not isolated, you should
take special care when defining them.
○ Could blow up everything if you use common
names for classes. Watch out!
Deeper into Engines
○ Read more about Engines:
○ Rails::Engine - Ruby On Rails API Online
http://api.rubyonrails.org/classes/Rails/Engine.html
○ Try yourself building an Engine - Ruby on Rails
Guides
http://guides.rubyonrails.org/engines.html
Last but not least
"Gemify" your Engine
Gemify your Engine
○ Check you have correctly defined your .
gemspec file.
○ Run gem build <name>.gemspec.
○ Then install it with gem install .
/<name>.gem.
○ You can add it to Bundler's Gemfile
passing a :path key in your options hash.
○ And, well, that's pretty much everything I
wanted to cover here.
Thank you for your time!
2013

Weitere ähnliche Inhalte

Andere mochten auch

Modal verbs
Modal verbsModal verbs
Modal verbs
mariamug
 
Recruitment
RecruitmentRecruitment
Recruitment
Sean Ray
 

Andere mochten auch (11)

Magaly
MagalyMagaly
Magaly
 
Modal verbs
Modal verbsModal verbs
Modal verbs
 
ΕΝΑ ΓΛΥΠΤΟ ΤΗΣ ΑΙΝΟΥ ΔΙΗΓΕΙΤΑΙ ΤΗΝ ΙΣΤΟΡΙΑ ΤΟΥ
ΕΝΑ ΓΛΥΠΤΟ ΤΗΣ ΑΙΝΟΥ ΔΙΗΓΕΙΤΑΙ ΤΗΝ ΙΣΤΟΡΙΑ ΤΟΥΕΝΑ ΓΛΥΠΤΟ ΤΗΣ ΑΙΝΟΥ ΔΙΗΓΕΙΤΑΙ ΤΗΝ ΙΣΤΟΡΙΑ ΤΟΥ
ΕΝΑ ΓΛΥΠΤΟ ΤΗΣ ΑΙΝΟΥ ΔΙΗΓΕΙΤΑΙ ΤΗΝ ΙΣΤΟΡΙΑ ΤΟΥ
 
παρουσιαση προγραμματος 2014
παρουσιαση προγραμματος 2014παρουσιαση προγραμματος 2014
παρουσιαση προγραμματος 2014
 
"Η ΑΝΤΑΛΛΑΓΗ των ΠΛΗΘΥΣΜΩΝ μετά τη ΣΥΝΘΗΚΗ της ΛΟΖΑΝΗΣ. Η ΜΟΙΡΑ του ΠΡΟΣΦΥΓΑ"
"Η ΑΝΤΑΛΛΑΓΗ των ΠΛΗΘΥΣΜΩΝ μετά τη ΣΥΝΘΗΚΗ της ΛΟΖΑΝΗΣ. Η ΜΟΙΡΑ του ΠΡΟΣΦΥΓΑ""Η ΑΝΤΑΛΛΑΓΗ των ΠΛΗΘΥΣΜΩΝ μετά τη ΣΥΝΘΗΚΗ της ΛΟΖΑΝΗΣ. Η ΜΟΙΡΑ του ΠΡΟΣΦΥΓΑ"
"Η ΑΝΤΑΛΛΑΓΗ των ΠΛΗΘΥΣΜΩΝ μετά τη ΣΥΝΘΗΚΗ της ΛΟΖΑΝΗΣ. Η ΜΟΙΡΑ του ΠΡΟΣΦΥΓΑ"
 
ΚΩΝΣΤΑΝΤΙΝΟΥΠΟΛΗ - ΠΑΡΕΛΘΟΝ/ΠΑΡΟΝ
ΚΩΝΣΤΑΝΤΙΝΟΥΠΟΛΗ - ΠΑΡΕΛΘΟΝ/ΠΑΡΟΝΚΩΝΣΤΑΝΤΙΝΟΥΠΟΛΗ - ΠΑΡΕΛΘΟΝ/ΠΑΡΟΝ
ΚΩΝΣΤΑΝΤΙΝΟΥΠΟΛΗ - ΠΑΡΕΛΘΟΝ/ΠΑΡΟΝ
 
το πολιτιστικο γιγνεσθαι της ισπανιας
το πολιτιστικο γιγνεσθαι της ισπανιαςτο πολιτιστικο γιγνεσθαι της ισπανιας
το πολιτιστικο γιγνεσθαι της ισπανιας
 
βιωματικη α3
βιωματικη α3βιωματικη α3
βιωματικη α3
 
RSpec 3: The new, the old, the good
RSpec 3: The new, the old, the goodRSpec 3: The new, the old, the good
RSpec 3: The new, the old, the good
 
Recruitment
RecruitmentRecruitment
Recruitment
 
DIDÁCTICA CRÍTICA
DIDÁCTICA CRÍTICA DIDÁCTICA CRÍTICA
DIDÁCTICA CRÍTICA
 

Ähnlich wie A story about gemified engines

Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Andy Maleh
 
Content Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainContent Management That Won't Rot Your Brain
Content Management That Won't Rot Your Brain
Sean Cribbs
 
Rails engines in large apps
Rails engines in large appsRails engines in large apps
Rails engines in large apps
Enrico Teotti
 
Building Websites Using ASP.NET Core Razor Pages
Building Websites Using ASP.NET Core Razor PagesBuilding Websites Using ASP.NET Core Razor Pages
Building Websites Using ASP.NET Core Razor Pages
ssusere19c741
 

Ähnlich wie A story about gemified engines (20)

How to set up and test a Rails 3 Engine
How to set up and test a Rails 3 EngineHow to set up and test a Rails 3 Engine
How to set up and test a Rails 3 Engine
 
Carbon and OSGi Deep Dive
Carbon and OSGi Deep DiveCarbon and OSGi Deep Dive
Carbon and OSGi Deep Dive
 
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
Revised Rails Engine Patterns for Montreal.rb meetup Oct 16, 2012
 
Rails Concept
Rails ConceptRails Concept
Rails Concept
 
West Yorkshire Mulesoft Meetup #6
West Yorkshire Mulesoft Meetup #6West Yorkshire Mulesoft Meetup #6
West Yorkshire Mulesoft Meetup #6
 
Content Management That Won't Rot Your Brain
Content Management That Won't Rot Your BrainContent Management That Won't Rot Your Brain
Content Management That Won't Rot Your Brain
 
Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8Building a Custom Theme in Drupal 8
Building a Custom Theme in Drupal 8
 
Beyond rails new
Beyond rails newBeyond rails new
Beyond rails new
 
Building Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkBuilding Application with Ruby On Rails Framework
Building Application with Ruby On Rails Framework
 
Mythical Mysfits: Monolith to Microservice with Docker and AWS Fargate (CON21...
Mythical Mysfits: Monolith to Microservice with Docker and AWS Fargate (CON21...Mythical Mysfits: Monolith to Microservice with Docker and AWS Fargate (CON21...
Mythical Mysfits: Monolith to Microservice with Docker and AWS Fargate (CON21...
 
Ruby on Rails introduction
Ruby on Rails introduction Ruby on Rails introduction
Ruby on Rails introduction
 
Rails in the bowels
Rails in the bowelsRails in the bowels
Rails in the bowels
 
Rails engines in large apps
Rails engines in large appsRails engines in large apps
Rails engines in large apps
 
Lightning web components
Lightning web components Lightning web components
Lightning web components
 
DiUS Computing Lca Rails Final
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails Final
 
Building Websites Using ASP.NET Core Razor Pages
Building Websites Using ASP.NET Core Razor PagesBuilding Websites Using ASP.NET Core Razor Pages
Building Websites Using ASP.NET Core Razor Pages
 
Railties
RailtiesRailties
Railties
 
FOSDEM19 MySQL Component Infrastructure
FOSDEM19 MySQL Component InfrastructureFOSDEM19 MySQL Component Infrastructure
FOSDEM19 MySQL Component Infrastructure
 
MySQL Cluster Asynchronous replication (2014)
MySQL Cluster Asynchronous replication (2014) MySQL Cluster Asynchronous replication (2014)
MySQL Cluster Asynchronous replication (2014)
 
Onion Architecture with S#arp
Onion Architecture with S#arpOnion Architecture with S#arp
Onion Architecture with S#arp
 

Kürzlich hochgeladen

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Kürzlich hochgeladen (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 

A story about gemified engines

  • 1. A story about Gemified Engines A 45-minute introduction to Engines
  • 3. A few essential concepts ○ A Ruby Gem is a container for reusable Ruby code. ○ A Rails Gem is a Ruby Gem that depends on Rails. ○ To "gemify" something, is to create a Gem out of a piece of isolated Ruby code.
  • 4. Enlighten me! Quick intro to Railties & Engines
  • 5. Quick intro to Railties & Engines ○ Since version 3, Rails major components are built on top of a core class called Railtie. ○ Thus, all (new and old) components based on this class were dubbed "Railties". ○ This class "provides several hooks to extend Rails and/or modify the initialization process".1 [1] Taken from http://api.rubyonrails.org/classes/Rails/Railtie.html
  • 6. Quick intro to Railties & Engines ○ Railties are responsible for their own initialization/configuration process, making Rails core's independent from them -sort of a "plug & play" standard. ○ Obviously, we can create our own Railties and extend our application, much like any Rails Gem we know does.
  • 7. Quick intro to Railties & Engines ○ Read more about Railties: ○ Rails::Railtie - Ruby On Rails API Online http://api.rubyonrails.org/classes/Rails/Railtie.html
  • 8. Quick intro to Railties & Engines ○ An Engine is a Railtie. ○ Hence, an Engine can do all that that a Railtie can do, and more. ○ Internally, Engine inherits from Railtie, as you imagined.
  • 9. Quick intro to Railties & Engines ○ Engines are self-contained Rails applications. ○ Any Rails ~> 3 application is an Engine. ○ Engines you plug into your application integrate seamlessly adding their controllers, models, views, routes, etc. as if they were part of the whole thing. ○ They can also be isolated (namespaced) to avoid conflicts with the main application.
  • 11. Deeper into Engines ○ Engines are the way to extend any Rails 3 application by default. ○ They can be thought of as Plugins (sort of). ○ In fact, the Rails default generator for Engines is: rails plugin new <name> -- <type>. ○ Type can be full or mountable.
  • 12. Deeper into Engines ○ Mountable Engines ○ Namespace isolated by default. ○ Meaning: no name-clash conflicts with the "host" application. ○ All your controllers, models and routes get isolated inside the namespace. ○ The routes namespace name is defined when mounting the Engine routes in the routes.rb file. ○ This is a conservative approach.
  • 13. Deeper into Engines ○ Full Engines ○ No namespace isolation; everything you put in it will become available to the host application "as is". ○ Useful if you're adding functionality to existing resources. ○ Because routes are also not isolated, you should take special care when defining them. ○ Could blow up everything if you use common names for classes. Watch out!
  • 14. Deeper into Engines ○ Read more about Engines: ○ Rails::Engine - Ruby On Rails API Online http://api.rubyonrails.org/classes/Rails/Engine.html ○ Try yourself building an Engine - Ruby on Rails Guides http://guides.rubyonrails.org/engines.html
  • 15. Last but not least "Gemify" your Engine
  • 16. Gemify your Engine ○ Check you have correctly defined your . gemspec file. ○ Run gem build <name>.gemspec. ○ Then install it with gem install . /<name>.gem. ○ You can add it to Bundler's Gemfile passing a :path key in your options hash. ○ And, well, that's pretty much everything I wanted to cover here.
  • 17. Thank you for your time! 2013