Created
October 4, 2012 13:46
-
-
Save daveworth/3833619 to your computer and use it in GitHub Desktop.
A Widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Widget | |
attr_accessible :name, :feature | |
def display_title | |
"#{name} - #{rand(10)}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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