class ROM::SQL::Schema::AttributesInferrer

@api private

Constants

CONSTRAINT_DB_TYPE

Public Instance Methods

call(schema, gateway) click to toggle source

@api private

# File lib/rom/sql/schema/attributes_inferrer.rb, line 22
def call(schema, gateway)
  dataset = schema.name.dataset

  columns = filter_columns(gateway.connection.schema(dataset))

  inferred = columns.map do |name, definition|
    type = type_builder.(**definition)

    attr_class.new(type.meta(source: schema.name), name: name) if type
  end.compact

  missing = columns.map(&:first) - inferred.map { |attr| attr.name }

  [inferred, missing]
end
filter_columns(schema) click to toggle source

@api private

# File lib/rom/sql/schema/attributes_inferrer.rb, line 46
def filter_columns(schema)
  schema.reject { |_, definition| definition[:db_type] == CONSTRAINT_DB_TYPE }
end
with(new_options) click to toggle source

@api private

# File lib/rom/sql/schema/attributes_inferrer.rb, line 41
def with(new_options)
  self.class.new(options.merge(new_options))
end