Class: ROM::Files::Schema::AttributesInferrer Private
- Inherits:
-
Object
- Object
- ROM::Files::Schema::AttributesInferrer
- Extended by:
- Dry::Core::ClassAttributes, Initializer
- Defined in:
- lib/rom/files/schema/attributes_inferrer.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Direct Known Subclasses
Constant Summary collapse
- KNOWN_COLUMNS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ID].freeze
Instance Attribute Summary collapse
Class Method Summary collapse
- .[](mime_type) ⇒ AttributesInferrer private
- .register(type, inferrer) ⇒ AttributesInferrer private
- .registered?(type) ⇒ Boolean private
- .registry ⇒ Hash{String => AttributesInferrer}
Instance Method Summary collapse
- #build(type, name, schema) ⇒ Files::Attribute private
- #call(schema, gateway) ⇒ Object private
- #columns ⇒ Array<Symbol> private
- #infer_attributes(schema, _gateway) ⇒ Object private
- #with(new_options) ⇒ Object private
Instance Attribute Details
#attr_class ⇒ Class(Files::Attribute) (readonly)
43 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 43 option :attr_class, default: -> { self.class.attr_class } |
Class Method Details
.[](mime_type) ⇒ AttributesInferrer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 37 def self.[](mime_type) registry[mime_type] end |
.register(type, inferrer) ⇒ AttributesInferrer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 27 def self.register(type, inferrer) registry[type] = inferrer end |
.registered?(type) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
31 32 33 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 31 def self.registered?(type) registry.key?(type) end |
.registry ⇒ Hash{String => AttributesInferrer}
20 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 20 defines :registry, :attr_class |
Instance Method Details
#build(type, name, schema) ⇒ Files::Attribute
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 60 def build(type, name, schema) attr_class.new(type.(name: name, source: schema.name)) end |
#call(schema, gateway) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 52 53 54 55 |
# 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.[:name] } [inferred, missing] end |
#columns ⇒ Array<Symbol>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
65 66 67 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 65 def columns KNOWN_COLUMNS end |
#infer_attributes(schema, _gateway) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 73 def infer_attributes(schema, _gateway) [build(Types::Path, ID, schema)] end |
#with(new_options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/rom/files/schema/attributes_inferrer.rb', line 69 def with() self.class.new(.merge()) end |