Module: Decanter::Extensions

Defined in:
lib/decanter/extensions.rb

Defined Under Namespace

Modules: ActiveRecord, ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/decanter/extensions.rb', line 4

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#decant(args, **options) ⇒ Object



18
19
20
# File 'lib/decanter/extensions.rb', line 18

def decant(args, **options)
  self.class.decant(args, options)
end

#decant_update(args, **options) ⇒ Object



8
9
10
11
# File 'lib/decanter/extensions.rb', line 8

def decant_update(args, **options)
  self.attributes = self.class.decant(args, options)
  self.save(context: options[:context])
end

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



13
14
15
16
# File 'lib/decanter/extensions.rb', line 13

def decant_update!(args, **options)
  self.attributes = self.class.decant(args, options)
  self.save!(context: options[:context])
end