This file contains hidden or 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 IsEffectiveProductSpecification | |
def criteria | |
{ :conditions => ["effective_from => :today", { :today <= Date.today}] } | |
end | |
end |
This file contains hidden or 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 CompositeSpecification < Array | |
def all | |
self.inject(Product.scoped(nil)) do |combined_scope, specification| | |
combined_scope.scoped(specification.criteria) | |
end | |
end | |
end |
This file contains hidden or 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 Product | |
def self.select_satisfying(specification) | |
satisfying = specification.all | |
# apply more complex selection, such as selecting across different combination of model objects | |
end | |
end |
This file contains hidden or 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
def menu_items | |
@pages.find(:all, :in_directory => "/main", :sort_by => 'order') | |
end |
This file contains hidden or 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
<% menu_items.each do |page| %> | |
<% if is_current_page?(page) %> | |
<li class='current'><p><%= page.title %></p> </li> | |
<% else %> | |
<li><%= link_to_page(page) %></li> | |
<% end %> | |
<% end %> |
This file contains hidden or 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
<% @partials.find(:all, :in_directory => "/main") do |partial| %> | |
<div id='<%= partial.name %>' style='display: none'> | |
<div><%= render(:partial => partial) %></div> | |
</div> | |
<% end %> |
This file contains hidden or 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
--- | |
title: About Us | |
order: 1 | |
filter: erb | |
--- | |
<%= render(:partial => "main/about") %> |
This file contains hidden or 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
gemmate() { | |
mate $GEMDIR/gems/`$(which ls) $GEMDIR/gems | grep $1 | sort` | |
} | |
complete -o default -o nospace -F _gemdocomplete gemmate |
This file contains hidden or 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
# Ripped from cucumber-0.8.3/examples/watir/features/support/screenshots.rb | |
module Screenshots | |
if Cucumber::OS_X | |
def embed_screenshot(id) | |
`screencapture -t png reports/#{id}.png` | |
embed("#{id}.png", "image/png") | |
end | |
else | |
def embed_screenshot(id) | |
`import -window root reports/#{id}.png` |
This file contains hidden or 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
CouchRest.database("http://localhost:5984/messages") | |
db.save_doc({text: "first message", requested_at: Time.now, priority: "medium"}) |
OlderNewer