Sha256: f846ab296ec4791269fa6722478612c9f834347c380219e1bca428f7f91b6fbd
Contents?: true
Size: 944 Bytes
Versions: 4
Compression:
Stored size: 944 Bytes
Contents
module Decanter module Extensions def self.included(base) base.extend(ClassMethods) end def decant_update(args, **options) self.attributes = self.class.decant(args, options) self.save(context: options[:context]) end def decant_update!(args, **options) self.attributes = self.class.decant(args, options) self.save!(context: options[:context]) end module ClassMethods def decant_create(args, **options) self.new(decant(args, options)) .save(context: options[:context]) end def decant_new(args, **options) self.new(decant(args, options)) end def decant_create!(args, **options) self.new(decant(args, options)) .save!(context: options[:context]) end def decant(args, options) options.fetch(:decanter, Decanter.decanter_for(self)) .decant(args) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
decanter-0.6.2 | lib/decanter/extensions.rb |
decanter-0.6.1 | lib/decanter/extensions.rb |
decanter-0.6.0 | lib/decanter/extensions.rb |
decanter-0.5.5 | lib/decanter/extensions.rb |