Class: RspecApiDocumentation::Example
- Inherits:
-
Object
- Object
- RspecApiDocumentation::Example
show all
- Defined in:
- lib/rspec_api_documentation/example.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(example, configuration) ⇒ Example
Returns a new instance of Example.
5
6
7
8
|
# File 'lib/rspec_api_documentation/example.rb', line 5
def initialize(example, configuration)
@example = example
@configuration = configuration
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *args, &block) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/rspec_api_documentation/example.rb', line 10
def method_missing(method_sym, *args, &block)
if example.metadata.has_key?(method_sym)
example.metadata[method_sym]
else
example.send(method_sym, *args, &block)
end
end
|
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
3
4
5
|
# File 'lib/rspec_api_documentation/example.rb', line 3
def configuration
@configuration
end
|
#example ⇒ Object
Returns the value of attribute example.
3
4
5
|
# File 'lib/rspec_api_documentation/example.rb', line 3
def example
@example
end
|
Instance Method Details
#explanation ⇒ Object
53
54
55
|
# File 'lib/rspec_api_documentation/example.rb', line 53
def explanation
metadata[:explanation] || nil
end
|
#has_attributes? ⇒ Boolean
41
42
43
|
# File 'lib/rspec_api_documentation/example.rb', line 41
def has_attributes?
respond_to?(:attributes) && attributes.present?
end
|
#has_parameters? ⇒ Boolean
37
38
39
|
# File 'lib/rspec_api_documentation/example.rb', line 37
def has_parameters?
respond_to?(:parameters) && parameters.present?
end
|
#has_response_fields? ⇒ Boolean
45
46
47
|
# File 'lib/rspec_api_documentation/example.rb', line 45
def has_response_fields?
respond_to?(:response_fields) && response_fields.present?
end
|
#http_method ⇒ Object
22
23
24
|
# File 'lib/rspec_api_documentation/example.rb', line 22
def http_method
metadata[:method].to_s.upcase
end
|
#public? ⇒ Boolean
33
34
35
|
# File 'lib/rspec_api_documentation/example.rb', line 33
def public?
metadata[:public]
end
|
#requests ⇒ Object
57
58
59
|
# File 'lib/rspec_api_documentation/example.rb', line 57
def requests
(metadata[:requests]) || []
end
|
#resource_explanation ⇒ Object
49
50
51
|
# File 'lib/rspec_api_documentation/example.rb', line 49
def resource_explanation
metadata[:resource_explanation] || nil
end
|
#respond_to?(method_sym, include_private = false) ⇒ Boolean
18
19
20
|
# File 'lib/rspec_api_documentation/example.rb', line 18
def respond_to?(method_sym, include_private = false)
super || example.metadata.has_key?(method_sym) || example.respond_to?(method_sym, include_private)
end
|
#should_document? ⇒ Boolean
26
27
28
29
30
31
|
# File 'lib/rspec_api_documentation/example.rb', line 26
def should_document?
return false if pending? || !metadata[:resource_name] || !metadata[:document]
return false if (Array(metadata[:document]) & Array(configuration.exclusion_filter)).length > 0
return true if (Array(metadata[:document]) & Array(configuration.filter)).length > 0
return true if configuration.filter == :all
end
|