class ROM::Files::Schema::AttributesInferrer

@api private

Constants

KNOWN_COLUMNS

Public Class Methods

[](mime_type) click to toggle source

@param mime_type [String] @return [AttributesInferrer]

# File lib/rom/files/schema/attributes_inferrer.rb, line 37
def self.[](mime_type)
  registry[mime_type]
end
register(type, inferrer) click to toggle source

@param type [String] @param inferrer [AttributesInferrer] @return [AttributesInferrer]

# File lib/rom/files/schema/attributes_inferrer.rb, line 27
def self.register(type, inferrer)
  registry[type] = inferrer
end
registered?(type) click to toggle source
# File lib/rom/files/schema/attributes_inferrer.rb, line 31
def self.registered?(type)
  registry.key?(type)
end

Public Instance Methods

build(type, name, schema) click to toggle source

@return [Files::Attribute]

# File lib/rom/files/schema/attributes_inferrer.rb, line 60
def build(type, name, schema)
  attr_class.new(type.meta(name: name, source: schema.name))
end
call(schema, gateway) click to toggle source

@param schema [ROM::Files::Schema] @param gateway [ROM::Files::Gateway]

@api private

# File lib/rom/files/schema/attributes_inferrer.rb, line 49
def call(schema, gateway)
  inferred = infer_attributes(schema, gateway)

  missing = columns - inferred.map { |attr| attr.meta[:name] }

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

@return [Array<Symbol>]

# File lib/rom/files/schema/attributes_inferrer.rb, line 65
def columns
  KNOWN_COLUMNS
end
infer_attributes(schema, _gateway) click to toggle source
# File lib/rom/files/schema/attributes_inferrer.rb, line 73
def infer_attributes(schema, _gateway)
  [build(Types::Path, ID, schema)]
end
with(new_options) click to toggle source
# File lib/rom/files/schema/attributes_inferrer.rb, line 69
def with(new_options)
  self.class.new(options.merge(new_options))
end