!SLIDE
"Follow your nose"
— Roy T. Fielding
!SLIDE
"build scalable, flexible implementations that do not simply run on the Web, but that actually exist in the Web"
Inheritance is a key concept in most object-oriented languages, but applying it skillfully can be challenging in practice. Back in 1989, M. Sakkinen wrote a paper called Disciplined inheritance that addresses these problems and offers some useful criteria for working around them. Despite being more than two decades old, this paper is extremely relevant to the modern Ruby programmer.
Sakkinen's central point seems to be that most traditional uses of inheritance lead to poor encapsulation, bloated object contracts, and accidental namespace collisions. He provides two patterns for disciplined inheritance and suggests that by normalizing the way that we model things, we can apply these two patterns to a very wide range of scenarios. He goes on to show that code that conforms to these design rules can easily be modeled as ordinary object composition, exposing a solid alternative to tradi
// http://chaijs.com/guide/plugins/ | |
module.exports = function(chai, utils){ | |
var Assertion = chai.Assertion | |
, assert = chai.assert | |
Assertion.addProperty('resource', function(){ | |
var doc = this._obj | |
, message = utils.flag(this, 'message') | |
new Assertion(doc, message).to.be.an('object') |
class Organization | |
def to_param | |
"42" | |
end | |
def saved? | |
rand > 0.5 | |
end | |
end | |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
{ | |
"title": "Catalog for Domenic, page 1", | |
"description": "Contains lots of books, which is cool", | |
"_links": { | |
"self": { "href": "/docs?page=1" }, | |
"next": { "href": "/docs?page=2" } | |
}, | |
"_embedded": { | |
"http://rel.nkstdy.co/document": [ | |
{ |
class BrandSweeper < ActionController::Caching::Sweeper | |
observe Brand # Observers will introspect on the class, but Sweepers don't | |
def after_update(brand) | |
expire_action :controller => "brand", :action => :preview, :brand_id => brand.to_param | |
end | |
... |
~/Code/ember.js ‹ruby-1.9.3› ‹master*› $ bundle && echo "fuck you giles" | |
Using rake (0.9.2.2) | |
Using confparser (0.0.2.1) | |
Using multi_json (1.0.4) | |
Using execjs (1.2.13) | |
Using libxml-ruby (2.2.2) | |
Using faster_xml_simple (0.5.0) | |
Using httpclient (2.2.4) | |
Using json (1.6.5) | |
Using nokogiri (1.5.0) |
# Rails3 way to redirect non-www domain to www domain | |
# Single domain redirect | |
'example.com'.tap do |host| | |
constraints(:host => host) do | |
match '/(*path)', :to => redirect { |params, request| Addressable::URI.escape request.url.sub(host, "www.#{host}") } | |
end | |
end | |
{ | |
"self": {"href":"/orders"}, | |
"rel-templates":[ | |
{ | |
"name":"ea", | |
"href":"http://example.com/docs/rels/{rel}", | |
"templated":true | |
} | |
], | |
"next":{"href": "/orders?page=2"}, |