Skip to content

Instantly share code, notes, and snippets.

@daveworth
Created October 4, 2012 13:46
Show Gist options
  • Save daveworth/3833619 to your computer and use it in GitHub Desktop.
Save daveworth/3833619 to your computer and use it in GitHub Desktop.
A Widget
class WidgetDecorator::Base < ApplicationDecorator
def display_title
""
end
end
class WidgetDecorator < WidgetDecorator::Base
decorates :widget
def display_title
#...
end
end
class MetalWidgetDecorator < WidgetDecorator::Base
decorates :metal_widget
def display_title
#...
end
end
class MetalWidget
attr_accessor :band_name, :number_of_demo_tapes
end
class MetalWidgetDecorator < ApplicationWidget
decorates :metal_widget
def display_title
<<-BAND_STUFF
We are #{band_name}! Thanks for coming. Please pick up one of our
#{number_of_demo_tapes} excellent early albums from the site before you go
BAND_STUFF
end
end
class Widget
attr_accessible :name, :feature
def display_title
"#{name} - #{rand(10)}"
end
end
class Widget
attr_accessible :name, :feature
end
class WidgetDecorator < ApplicationDecorator
decorates :widget
def display_title
"Hello, my name is #{name} - I've been in #{rand(10)} bands."
end
end
%h1 Widget!
%p
Name:
= @widget.display_title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment