Created
September 12, 2009 15:12
-
-
Save pacoguzman/185873 to your computer and use it in GitHub Desktop.
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 ActionDuck | |
attr_accessor :errors | |
def initialize(h) | |
h ||= {} | |
h.each { |k,v| send("#{k}=", v) } | |
self.errors = ActiveRecord::Errors.new(self) | |
end | |
# These make a class quack like an AR::Base | |
class << self | |
def self_and_descendants_from_active_record | |
[self] | |
end | |
def human_name | |
self.name.humanize | |
end | |
def human_attribute_name(attribute_key_name, options = {}) | |
attribute_key_name.to_s.humanize | |
end | |
end | |
# These make an instance quack like an AR::Base | |
def new_record? | |
true | |
end | |
def id | |
nil | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment