Module: Verifiable::Associations
- Defined in:
- lib/verifiable/associations.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #verification_code_for(object) ⇒ Object
- #verification_for(object) ⇒ Object
- #verify!(object, code) ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 |
# File 'lib/verifiable/associations.rb', line 3 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#verification_code_for(object) ⇒ Object
17 18 19 |
# File 'lib/verifiable/associations.rb', line 17 def verification_code_for(object) verification_for(object).code end |
#verification_for(object) ⇒ Object
21 22 23 |
# File 'lib/verifiable/associations.rb', line 21 def verification_for(object) Verification.find(:first, :conditions => {:object_id => object.id, :object_type => object.class.to_s, :verifiable_id => self.id, :verifiable_type => self.class.to_s}) || Verification.find(:first, :conditions => {:object_id => self.id, :object_type => self.class.to_s, :verifiable_id => object.id, :verifiable_type => object.class.to_s}) end |
#verify!(object, code) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/verifiable/associations.rb', line 7 def verify!(object, code) verification = verification_for(object) if code == verification.code verification.update_attributes(:verified_at => Time.now) true else false end end |