Module: Verifiable::Associations::ClassMethods
- Defined in:
- lib/verifiable/associations.rb
Instance Method Summary collapse
Instance Method Details
#has_many_verifiable(things, options = {}) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/verifiable/associations.rb', line 26 def has_many_verifiable(things, = {}) source_type = things.to_s.singularize.camelize has_many :verifications, :as => :object, :dependent => :destroy, :class_name => "Verifiable::Verification" unless reflect_on_association(:verifications) has_many things, :through => :verifications, :source => :verifiable, :source_type => source_type, :conditions => "verified_at IS NOT NULL" has_many "unverified_#{things}", :through => :verifications, :source => :verifiable, :source_type => source_type, :conditions => "verified_at IS NULL" end |
#verifiable_for(things, options = {}) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/verifiable/associations.rb', line 33 def verifiable_for(things, = {}) source_type = things.to_s.singularize.camelize has_many :verifications, :as => :verifiable, :dependent => :destroy, :class_name => "Verifiable::Verification" unless reflect_on_association(:verifications) has_many things, :through => :verifications, :source => :object, :source_type => source_type, :conditions => "verified_at IS NOT NULL" has_many "unverified_#{things}", :through => :verifications, :source => :object, :source_type => source_type, :conditions => "verified_at IS NULL" end |