Module: Decanter::Extensions::ClassMethods

Defined in:
lib/decanter/extensions.rb

Instance Method Summary collapse

Instance Method Details

#decant(args, options = {}) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/decanter/extensions.rb', line 38

def decant(args, options = {})
  if (specified_decanter = options[:decanter])
    Decanter.decanter_from(specified_decanter)
  else
    Decanter.decanter_for(self)
  end.decant(args)
end

#decant_create(args, **options) ⇒ Object



24
25
26
27
# File 'lib/decanter/extensions.rb', line 24

def decant_create(args, **options)
  new(decant(args, options))
    .save(context: options[:context])
end

#decant_create!(args, **options) ⇒ Object



33
34
35
36
# File 'lib/decanter/extensions.rb', line 33

def decant_create!(args, **options)
  new(decant(args, options))
    .save!(context: options[:context])
end

#decant_new(args, **options) ⇒ Object



29
30
31
# File 'lib/decanter/extensions.rb', line 29

def decant_new(args, **options)
  new(decant(args, options))
end