Skip to content

Instantly share code, notes, and snippets.

@shepmaster
shepmaster / privacy_filter.rb
Created December 12, 2011 04:15 — forked from steveklabnik/privacy_filter.rb
A spec for a filter
class PrivacyFilter
class << self
def filter(controller)
@controller = controller
first_article? or administrator? or user?
end
def first_article?
@controller.params[:id] == 1
# Replace Inheritance with Delegation
# http://refactoring.com/catalog/replaceInheritanceWithDelegation.html
# class Roster < Array
# attr_accessor :title
# def to_s
# out = "#{title}\n"
# each do |item|
# out += "#{item}\n"