Module: Dynashard::ValidationExtensions

Defined in:
lib/dynashard/validations.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/dynashard/validations.rb', line 3

def self.included(base)
  base.alias_method_chain :find_finder_class_for, :dynashard
end

Instance Method Details

#find_finder_class_for_with_dynashard(record) ⇒ Object

Return the class that should be used to find other instances of the specified record’s model class. If the record is an instance of a sharded model, it should be used; otherwise the default behavior should be used.



11
12
13
14
15
16
17
18
19
# File 'lib/dynashard/validations.rb', line 11

def find_finder_class_for_with_dynashard(record)
  if record.class.dynashard_model?
    record.class
  elsif record.class.sharding_enabled?
    record.class.dynashard_sharded_subclass
  else
    find_finder_class_for_without_dynashard(record)
  end
end