lib/rails/graphql/helpers/leaf_from_ar.rb
def define_for(adapter, **settings)
          adapter = ar_adapters[adapter] if ar_adapters.key?(adapter)
          raise ArgumentError, <<~MSG.squish unless ar_adapters.values.include?(adapter)
            The given #{adapter.inspect} adapter is not a valid option.
            The valid options are: #{ar_adapters.to_a.flatten.map(&:inspect).to_sentence}.
          MSG

          define_singleton_method("from_#{adapter}_adapter", &settings[:fetch]) \
            if settings.key?(:fetch)

          define_singleton_method("cast_#{adapter}_attribute", &settings[:cast]) \
            if settings.key?(:cast)

          ar_adapter_type[adapter] = settings[:type] if settings.key?(:type)
          ar_adapter_aliases[adapter] += Array.wrap(settings[:aliases]) \
            if settings.key?(:aliases)
        end
# Helper method that should be used for ActiveRecord adapters in order
# to provide the correct methods and settings for retrieving the given
# value direct from a query.
#
# ==== Options
#
# * <tt>:fetch</tt> - A specific function to build the arel for fetching the attribute
# * <tt>:cast</tt> - A function to cast an attribute to the correct value
# * <tt>:type</tt> - A symbol that represents the exactly database type that matches
#   the ActiveRecord type (ie. :varchar for :string)
# * <tt>:aliases</tt> - An array of AR aliases that for the adapter they are
#   equivalent
Helper method that should be used for ActiveRecord adapters in order
to provide the correct methods and settings for retrieving the given
value direct from a query.

Options

:fetch - A specific function to build the arel for fetching the attribute
:cast - A function to cast an attribute to the correct value
:type - A symbol that represents the exactly database type that matches
the ActiveRecord type
:aliases - An array of AR aliases that for the adapter they are
equivalent
Helper method that should be used for ActiveRecord adapters in order to provide the correct methods and settings for retrieving the given value direct from a query . Options : fetch - A specific function to build the arel for fetching the attribute : cast - A function to cast an attribute to the correct value : type - A symbol that represents the exactly database type that matches the ActiveRecord type : aliases - An array of AR aliases that for the adapter they are equivalent
def define_for(adapter, **settings)
          adapter = ar_adapters[adapter] if ar_adapters.key?(adapter)
          raise ArgumentError, <<~MSG.squish unless ar_adapters.values.include?(adapter)
            The given #{adapter.inspect} adapter is not a valid option.
            The valid options are: #{ar_adapters.to_a.flatten.map(&:inspect).to_sentence}.
          MSG
          define_singleton_method("from_#{adapter}_adapter", &settings[:fetch]) \
            if settings.key?(:fetch)
          define_singleton_method("cast_#{adapter}_attribute", &settings[:cast]) \
            if settings.key?(:cast)
          ar_adapter_type[adapter] = settings[:type] if settings.key?(:type)
          ar_adapter_aliases[adapter] += Array.wrap(settings[:aliases]) \
            if settings.key?(:aliases)
        end
def define_for ( adapter , ** settings ) adapter = ar_adapters [ adapter ] if ar_adapters . key? ( adapter ) raise ArgumentError , <<~MSG . squish unless ar_adapters . values . include? ( adapter ) 
            The given  #{ adapter . inspect }  adapter is not a valid option.
            The valid options are:  #{ ar_adapters . to_a . flatten . map ( & :inspect ) . to_sentence } .
           MSG define_singleton_method ( "from_#{adapter}_adapter" , & settings [ :fetch ] ) if settings . key? ( :fetch ) define_singleton_method ( "cast_#{adapter}_attribute" , & settings [ :cast ] ) if settings . key? ( :cast ) ar_adapter_type [ adapter ] = settings [ :type ] if settings . key? ( :type ) ar_adapter_aliases [ adapter ] += Array . wrap ( settings [ :aliases ] ) if settings . key? ( :aliases ) end
Helper method that should be used for ActiveRecord adapters in order
to provide the correct methods and settings for retrieving the given
value direct from a query.
Helper method that should be used for ActiveRecord adapters in order to provide the correct methods and settings for retrieving the given value direct from a query .
adapter
settings