Class: Rage::OpenAPI::Parsers::Ext::Blueprinter
- Inherits:
-
Object
- Object
- Rage::OpenAPI::Parsers::Ext::Blueprinter
show all
- Defined in:
- lib/rage/openapi/parsers/ext/blueprinter.rb
Defined Under Namespace
Classes: Visitor, VisitorContext
Instance Method Summary
collapse
Constructor Details
#initialize(namespace: Object, root: Rage::OpenAPI::Nodes::Root.new) ⇒ Blueprinter
Returns a new instance of Blueprinter.
4
5
6
7
|
# File 'lib/rage/openapi/parsers/ext/blueprinter.rb', line 4
def initialize(namespace: Object, root: Rage::OpenAPI::Nodes::Root.new, **)
@namespace = namespace
@root = root
end
|
Instance Method Details
#__parse(klass_str) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/rage/openapi/parsers/ext/blueprinter.rb', line 21
def __parse(klass_str)
is_collection, klass_str, _ = Rage::OpenAPI.__parse_serializer_args(klass_str)
klass = @namespace.const_get(klass_str)
source_path, _ = Object.const_source_location(klass.name)
ast = Prism.parse_file(source_path)
visitor = Visitor.new(self, is_collection)
ast.value.accept(visitor)
visitor
end
|
#known_definition?(str) ⇒ Boolean
9
10
11
12
13
14
|
# File 'lib/rage/openapi/parsers/ext/blueprinter.rb', line 9
def known_definition?(str)
_, str, _ = Rage::OpenAPI.__parse_serializer_args(str)
defined?(Blueprinter::Base) && @namespace.const_get(str).ancestors.include?(Blueprinter::Base)
rescue NameError
false
end
|
#parse(klass_str) ⇒ Object
16
17
18
19
|
# File 'lib/rage/openapi/parsers/ext/blueprinter.rb', line 16
def parse(klass_str)
visitor = __parse(klass_str)
visitor.build_schema
end
|