Skip to content

Instantly share code, notes, and snippets.

@agmcleod
Created September 7, 2012 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agmcleod/3669117 to your computer and use it in GitHub Desktop.
Save agmcleod/3669117 to your computer and use it in GitHub Desktop.
meta programming/inflector test
require 'rubygems'
require 'active_support/all'
class MyClass
def skills
[]
end
def unions
[]
end
def companies
[]
end
def clients
[]
end
def schools
[]
end
def statuses
[]
end
end
class ActivityDashboard
def initialize(*args)
end
end
current_user = MyClass.new
@your_activity = []
["skill", "union", "company", "client", "school", "status"].each do |type|
plural = ActiveSupport::Inflector.pluralize(type)
@your_activity += current_user.send(plural.to_sym).map do |object|
ActivityDashboard.new("#{current_user.first_name} #{current_user.last_name}","#{current_user.id}","#{current_user.avatar}",type, object, object.created_at)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment