Class: RSpec::Rails::Swagger::Document
- Inherits:
-
Object
- Object
- RSpec::Rails::Swagger::Document
- Defined in:
- lib/rspec/rails/swagger/document.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
Instance Method Summary collapse
- #[](value) ⇒ Object
-
#initialize(data) ⇒ Document
constructor
A new instance of Document.
- #resolve_ref(ref) ⇒ Object
Constructor Details
#initialize(data) ⇒ Document
Returns a new instance of Document.
7 8 9 |
# File 'lib/rspec/rails/swagger/document.rb', line 7 def initialize(data) @data = data.deep_symbolize_keys end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/rspec/rails/swagger/document.rb', line 5 def data @data end |
Instance Method Details
#[](value) ⇒ Object
11 12 13 |
# File 'lib/rspec/rails/swagger/document.rb', line 11 def [](value) data[value] end |
#resolve_ref(ref) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rspec/rails/swagger/document.rb', line 15 def resolve_ref(ref) unless %r{#/(?<location>parameters|definitions)/(?<name>.+)} =~ ref raise ArgumentError, "Invalid reference: #{ref}" end result = data.fetch(location.to_sym, {})[name.to_sym] raise ArgumentError, "Reference value does not exist: #{ref}" unless result if location == 'parameters' result.merge(name: name) end result end |