Class: ROM::Repository::StructBuilder Private

Inherits:
Object
  • Object
show all
Extended by:
Dry::Core::Cache
Defined in:
lib/rom/repository/struct_builder.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.

Instance Method Summary collapse

Instance Method Details

#call(*args) ⇒ Object Also known as: []

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.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rom/repository/struct_builder.rb', line 15

def call(*args)
  fetch_or_store(*args) do
    name, header = args
    attributes = visit(header).compact

    if attributes.empty?
      ROM::OpenStruct
    else
      build_class(name, ROM::Struct) do |klass|
        attributes.each do |(name, type)|
          klass.attribute(name, type)
        end
      end
    end
  end
end