Sometimes relationships need to be flexible, and that's where we look to polymorphism. Say we want to implement:
- A
Person - A
Company - A
PhoneNumberthat can connect to aPersonor aCompany
| def output name=((default=true); "caius") | |
| puts "name: #{name.inspect}" | |
| puts "default: #{default.inspect}" | |
| end | |
| output | |
| # >> name: "caius" | |
| # >> default: true | |
| output "avdi" |
| $('#products').append('<%= j render(@products) %>'); | |
| <% if @products.next_page %> | |
| $('.pagination').replaceWith('<%= j will_paginate(@products) %>'); | |
| <% else %> | |
| $('.pagination').remove(); | |
| <% end %> |
| def maybe_a_sandwich | |
| nil | |
| end | |
| # Methods that might return nil are annoying. We want to write a nice | |
| # confident chain: | |
| result = nil | |
| result = maybe_a_sandwich.add_horseradish.get_into_my_belly! rescue $! | |
| result # => #<NoMethodError: undefined method `add_horseradish' for nil:NilClass> |
| rvm use @$(basename `pwd`) --create |
| /** | |
| Sample Propane caveatPatchor.js file based on tmm1's avatar hack. | |
| You'll need at least version 1.1.1 to experiment with this: | |
| http://propaneapp.com/appcast/Propane.1.1.1.zip | |
| Once I'm sure exposing this hack-injection point doesn't cause problems | |
| I'll do an official auto-updating version. | |
| As of version 1.1.1, Propane will load and execute the contents of |
| # Functional test just to demonstrate that everything is hooked up | |
| describe UsersController, "POST create", :type => :controller do | |
| before(:each) do | |
| UsersController.dispatcher = DefaultDispatcher | |
| end | |
| context "successful" do | |
| it "should create a user" do | |
| lambda { |