Module: Saasable::Mongoid::ScopedDocument::ClassMethods

Defined in:
lib/saasable/mongoid/scoped_document.rb

Instance Method Summary collapse

Instance Method Details

#index_with_saasable(spec, options = {}) ⇒ Object



47
48
49
# File 'lib/saasable/mongoid/scoped_document.rb', line 47

def index_with_saasable(spec, options = {})
  index_without_saasable({saas_id: 1}.merge(spec), options)
end

#validates_uniqueness_of(*args) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/saasable/mongoid/scoped_document.rb', line 39

def validates_uniqueness_of(*args)
  attributes = _merge_attributes(args)
  attributes[:scope] ||= []
  attributes[:scope] << :saas_id unless attributes[:scope].include?(:saas_id)

  validates_with(Mongoid::Validatable::UniquenessValidator, attributes)
end