lib/rom/repository/struct_builder.rb in rom-repository-1.3.2 vs lib/rom/repository/struct_builder.rb in rom-repository-1.3.3
- old
+ new
@@ -28,10 +28,16 @@
end
end
end
alias_method :[], :call
+ attr_reader :namespace
+
+ def initialize(namespace = nil)
+ @namespace = namespace || ROM::Struct
+ end
+
private
def visit(ast)
name, node = ast
__send__("visit_#{name}", node)
@@ -64,14 +70,14 @@
def visit_attribute(attr)
[attr.aliased? && !attr.wrapped? ? attr.alias : attr.name, attr.to_read_type]
end
def build_class(name, parent, &block)
- Dry::Core::ClassBuilder.new(name: class_name(name), parent: parent).call(&block)
+ Dry::Core::ClassBuilder.new(name: class_name(name), parent: parent, namespace: namespace).call(&block)
end
def class_name(name)
- "ROM::Struct[#{Dry::Core::Inflector.classify(Dry::Core::Inflector.singularize(name))}]"
+ Dry::Core::Inflector.classify(Dry::Core::Inflector.singularize(name))
end
end
end
end