Module: Decanter::Extensions::ClassMethods

Defined in:
lib/decanter/extensions.rb

Instance Method Summary collapse

Instance Method Details

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



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

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



22
23
24
25
# File 'lib/decanter/extensions.rb', line 22

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

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



31
32
33
34
# File 'lib/decanter/extensions.rb', line 31

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

#decant_new(args, **options) ⇒ Object



27
28
29
# File 'lib/decanter/extensions.rb', line 27

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