Skip to content

Instantly share code, notes, and snippets.

@timurvafin
Created February 22, 2011 13:52
Show Gist options
  • Save timurvafin/838687 to your computer and use it in GitHub Desktop.
Save timurvafin/838687 to your computer and use it in GitHub Desktop.
Post.fetch # fetch post from remote resources and save to the Post
Post::Tumblr.fetch # fetch post from Tumblr and save to the Post
# skinnycms/app/models/post.rb
class Post < ActiveRecord::Base
cattr_accessor :plugins
def fetch
plugins.each do |plugin|
Post.constantize(plugin).fetch
end
end
end
# skinnycms/app/models/post/base.rb
class Post::Base
end
# skinnycms_wordpress/init.rb
require 'app/models/post/wordpress'
Post.plugins << 'wordpress'
# skinnycms_wordpress/app/models/post/wordpress.rb
class Post::Wordpress < Post::Base
def self.fetch
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment