2010-05-08 20:27:49 +00:00
|
|
|
class Topic
|
|
|
|
include ActiveModel::Validations
|
2010-08-20 14:17:29 +00:00
|
|
|
include ActiveModel::Validations::Callbacks
|
2010-05-08 20:27:49 +00:00
|
|
|
|
2011-02-06 00:00:57 +00:00
|
|
|
def self._validates_default_keys
|
|
|
|
super | [ :message ]
|
|
|
|
end
|
|
|
|
|
2010-05-08 20:27:49 +00:00
|
|
|
attr_accessor :title, :author_name, :content, :approved
|
2010-08-20 14:17:29 +00:00
|
|
|
attr_accessor :after_validation_performed
|
|
|
|
|
|
|
|
after_validation :perform_after_validation
|
2010-05-08 20:27:49 +00:00
|
|
|
|
|
|
|
def initialize(attributes = {})
|
|
|
|
attributes.each do |key, value|
|
|
|
|
send "#{key}=", value
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-03-20 15:07:49 +00:00
|
|
|
def condition_is_true
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def condition_is_true_but_its_not
|
|
|
|
false
|
|
|
|
end
|
2010-08-20 14:17:29 +00:00
|
|
|
|
|
|
|
def perform_after_validation
|
|
|
|
self.after_validation_performed = true
|
|
|
|
end
|
|
|
|
|
2009-03-20 15:07:49 +00:00
|
|
|
end
|