Meta Programming in Ruby - Code Camp 2010
by ssoroka
- 3,800 views
meta programming in ruby
meta programming in ruby
code camp 2010
steven soroka
Accessibility
Categories
Upload Details
Uploaded via SlideShare as Apple Keynote
Usage Rights
© All Rights Reserved
Statistics
- Likes
- 16
- Downloads
- 239
- Comments
- 0
- Embed Views
- Views on SlideShare
- 3,765
- Total Views
- 3,800
No libraries to import, no main declaration, no instantiation of string classes
This, is a thing of beauty.
Notice I don’t have to declare the type of the car variable, it’s automatically assigned at runtime.
Notice I don’t have to declare the type of the car variable, it’s automatically assigned at runtime.
Notice I don’t have to declare the type of the car variable, it’s automatically assigned at runtime.
Notice I don’t have to declare the type of the car variable, it’s automatically assigned at runtime.
Notice I don’t have to declare the type of the car variable, it’s automatically assigned at runtime.
Notice I don’t have to declare the type of the car variable, it’s automatically assigned at runtime.
Notice I don’t have to declare the type of the car variable, it’s automatically assigned at runtime.
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
If you can judge that by the number of Ruby implementations, then I’d say so.
IronMonkey is Adobe VM
HotRuby is Ruby interpreter implemented in JS
IronRuby is Microsoft’s work towards Ruby.NET
We’re going to cover a lot of topics really quickly, so keep up. :)
less important @@
global $, if you litter your code with these; your peers will surprise you at how creative they can be when it comes to hiding your lifeless body.
less important @@
global $, if you litter your code with these; your peers will surprise you at how creative they can be when it comes to hiding your lifeless body.
less important @@
global $, if you litter your code with these; your peers will surprise you at how creative they can be when it comes to hiding your lifeless body.
less important @@
global $, if you litter your code with these; your peers will surprise you at how creative they can be when it comes to hiding your lifeless body.
In Ruby, symbols are mostly used as hash keys, column names, for referencing data types, or used as contant values, but they are not just cheap strings.
In Ruby, symbols are mostly used as hash keys, column names, for referencing data types, or used as contant values, but they are not just cheap strings.
In Ruby, symbols are mostly used as hash keys, column names, for referencing data types, or used as contant values, but they are not just cheap strings.
In Ruby, symbols are mostly used as hash keys, column names, for referencing data types, or used as contant values, but they are not just cheap strings.
;; you can fetch the value for the keys
;; you can fetch the value for the keys
;; you can fetch the value for the keys
;; you can fetch the value for the keys
;; you can fetch the value for the keys
;; you can fetch the value for the keys
OCP is ..
OCP is ..
OCP is ..
OCP is ..
Now 5.7.round always returns 5. This is clearly a double-edged sword. You want to open classes for extension, not for modification as we’ve done here. This violates the OCP
Now 5.7.round always returns 5. This is clearly a double-edged sword. You want to open classes for extension, not for modification as we’ve done here. This violates the OCP
Now 5.7.round always returns 5. This is clearly a double-edged sword. You want to open classes for extension, not for modification as we’ve done here. This violates the OCP
Now 5.7.round always returns 5. This is clearly a double-edged sword. You want to open classes for extension, not for modification as we’ve done here. This violates the OCP
Now 5.7.round always returns 5. This is clearly a double-edged sword. You want to open classes for extension, not for modification as we’ve done here. This violates the OCP
Now 5.7.round always returns 5. This is clearly a double-edged sword. You want to open classes for extension, not for modification as we’ve done here. This violates the OCP
Now 5.7.round always returns 5. This is clearly a double-edged sword. You want to open classes for extension, not for modification as we’ve done here. This violates the OCP
Using the braces is enough to denote that a hash object should be created
map iterates the items in the array and calls the block you supply for each item, returning a new array with the results
map iterates the items in the array and calls the block you supply for each item, returning a new array with the results
Now every array natively supports .sum. Rails gives you sum and .avg for free
Now every array natively supports .sum. Rails gives you sum and .avg for free
Now every array natively supports .sum. Rails gives you sum and .avg for free
Now every array natively supports .sum. Rails gives you sum and .avg for free
Now every array natively supports .sum. Rails gives you sum and .avg for free
Now every array natively supports .sum. Rails gives you sum and .avg for free
Now every array natively supports .sum. Rails gives you sum and .avg for free
Practically speaking, there’s a couple methods you don’t want to undefine, but lets just gloss over that.
class_eval - evaluates code in the context of the object’s class, or metaclass
instance_eval - evals code in the context of the object,
module_eval - evals in context of a module
ppl objects are interacting with our bmw differently
ppl objects are interacting with our bmw differently
ppl objects are interacting with our bmw differently
ppl objects are interacting with our bmw differently
ppl objects are interacting with our bmw differently
ppl objects are interacting with our bmw differently
ppl objects are interacting with our bmw differently
ppl objects are interacting with our bmw differently
the second it does much faster (finding a specific record). Now, in my experience with mysql, offset isn’t really that fast either, but lets call it negligible.
the second it does much faster (finding a specific record). Now, in my experience with mysql, offset isn’t really that fast either, but lets call it negligible.
the second it does much faster (finding a specific record). Now, in my experience with mysql, offset isn’t really that fast either, but lets call it negligible.
the second it does much faster (finding a specific record). Now, in my experience with mysql, offset isn’t really that fast either, but lets call it negligible.
the second it does much faster (finding a specific record). Now, in my experience with mysql, offset isn’t really that fast either, but lets call it negligible.
self-optimization-code similar to this is used by Rails internally for routing. The first time the method is called it generates its own routing methods based on a more complete picture of what’s required and cuts out a lot of dead cycles that would otherwise check routes that are never used.