Method: Decanter::Core::ClassMethods#unhandled_keys
- Defined in:
- lib/decanter/core.rb
#unhandled_keys(args) ⇒ Object
protected
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/decanter/core.rb', line 61 def unhandled_keys(args) unhandled_keys = args.keys.map(&:to_sym) - handlers.keys.flatten.uniq - handlers.values .select { |handler| handler[:type] != :input } .map { |handler| "#{handler[:name]}_attributes".to_sym } if unhandled_keys.any? case strict_mode when true p "#{self.name} ignoring unhandled keys: #{unhandled_keys.join(', ')}." {} when :with_exception raise ArgumentError.new("#{self.name} received unhandled keys: #{unhandled_keys.join(', ')}.") else args.select { |key| unhandled_keys.include? key } end else {} end end |