Method: NoBrainer::Document::Persistance#reload

Defined in:
lib/no_brainer/document/persistance.rb

#reload(options = {}) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/no_brainer/document/persistance.rb', line 41

def reload(options={})
  [:without, :pluck].each do |type|
    next unless v = options.delete(type)

    v = Hash[v.flatten.map { |k| [k, true] }] if v.is_a?(Array)
    v = {v => true} unless v.is_a?(Hash)
    v = v.select { |k,_v| _v }
    v = v.with_indifferent_access
    next unless v.present?

    options[:missing_attributes] ||= {}
    options[:missing_attributes][type] = v
  end
  _reload(options)
end