Created
February 4, 2012 04:34
-
-
Save dissolved/1735364 to your computer and use it in GitHub Desktop.
Alternative to Fig Leaf
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 Post | |
delegate :errors, :valid?, :save, :to => @record | |
@@persistance = Class.new(ActiveRecord::Base) do | |
set_table_name 'posts' | |
def self.name | |
'PostRecord' | |
end | |
end | |
def self.most_recent(limit=10) | |
@@persistence.all(order: "pubdate DESC", limit: limit) | |
end | |
def self.find(id) | |
Post.new(@@persistence.find(id)) | |
end | |
def initialize(object_or_hash = {}) | |
@record = object_or_hash === @@persistence ? object_or_hash : @@persistence.new(object_or_hash) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment