Class: APISpec::Object
- Inherits:
-
Node
- Object
- Node
- APISpec::Object
show all
- Defined in:
- lib/apispec/object.rb
Instance Attribute Summary
Attributes inherited from Node
#name, #parent
Instance Method Summary
collapse
Methods inherited from Node
#full_name, #node_path, #root?, #to_path, #to_s
Constructor Details
#initialize(name, &block) ⇒ Object
Returns a new instance of Object.
2
3
4
5
|
# File 'lib/apispec/object.rb', line 2
def initialize(name, &block)
@fields = []
super(name, &block)
end
|
Instance Method Details
#desc(value) ⇒ Object
7
8
9
|
# File 'lib/apispec/object.rb', line 7
def desc(value)
@desc = value
end
|
#example(format, value) ⇒ Object
19
20
21
|
# File 'lib/apispec/object.rb', line 19
def example(format, value)
@example = APISpec::Example.new(format, value)
end
|
#example_file(format, path) ⇒ Object
23
24
25
|
# File 'lib/apispec/object.rb', line 23
def example_file(format, path)
@example = [format, path]
end
|
#fields(*value) ⇒ Object
11
12
13
|
# File 'lib/apispec/object.rb', line 11
def fields(*value)
@fields = value
end
|
#resolve_references!(root_namespace) ⇒ Object
15
16
17
|
# File 'lib/apispec/object.rb', line 15
def resolve_references!(root_namespace)
@fields = @fields.map { |name| root_namespace.find_field(name) }.flatten
end
|
#to_html(generator) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/apispec/object.rb', line 27
def to_html(generator)
if @example.is_a? Array
format, path = @example
@example = APISpec::Example.new(format, File.read(generator.path(path)))
end
super(generator)
end
|