method

convert_dot_notation_to_hash

Importance_0
v7.1.3.2 - Show latest stable - 0 notes - Class: ActiveRecord::PredicateBuilder
convert_dot_notation_to_hash(attributes) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/relation/predicate_builder.rb, line 150
      def convert_dot_notation_to_hash(attributes)
        attributes.each_with_object({}) do |(key, value), converted|
          if value.is_a?(Hash)
            if (existing = converted[key])
              existing.merge!(value)
            else
              converted[key] = value.dup
            end
          elsif (idx = key.rindex("."))
            table_name, column_name = key[0, idx], key[idx + 1, key.length]

            if (existing = converted[table_name])
              existing[column_name] = value
            else
              converted[table_name] = { column_name => value }
            end
          else
            converted[key] = value
          end
        end
      end
Register or log in to add new notes.