Sha256: 2b3fbc0e3e16ab7ff2fb4b97115dbaa5e1dfa782b242174387edcef5e4ac9142
Contents?: true
Size: 946 Bytes
Versions: 1
Compression:
Stored size: 946 Bytes
Contents
# frozen_string_literal: true module Dynamoid module Criteria # @private class NonexistentFieldsDetector def initialize(conditions, source) @conditions = conditions @source = source @nonexistent_fields = nonexistent_fields end def found? @nonexistent_fields.present? end def warning_message return unless found? fields_list = @nonexistent_fields.map { |s| "`#{s}`" }.join(', ') count = @nonexistent_fields.size 'where conditions contain nonexistent ' \ "field #{'name'.pluralize(count)} #{fields_list}" end private def nonexistent_fields fields_from_conditions - fields_existent end def fields_from_conditions @conditions.keys.map { |s| s.to_s.split('.')[0].to_sym } end def fields_existent @source.attributes.keys.map(&:to_sym) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dynamoid-3.10.0 | lib/dynamoid/criteria/nonexistent_fields_detector.rb |