Class: Morpho::Grape::DataParser
- Inherits:
-
Object
- Object
- Morpho::Grape::DataParser
- Defined in:
- lib/morpho/grape/data_parser.rb
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(wrapper, endpoint) ⇒ DataParser
constructor
A new instance of DataParser.
Constructor Details
#initialize(wrapper, endpoint) ⇒ DataParser
Returns a new instance of DataParser.
7 8 9 10 |
# File 'lib/morpho/grape/data_parser.rb', line 7 def initialize(wrapper, endpoint) @wrapper = wrapper @endpoint = endpoint end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
5 6 7 |
# File 'lib/morpho/grape/data_parser.rb', line 5 def endpoint @endpoint end |
#wrapper ⇒ Object (readonly)
Returns the value of attribute wrapper.
4 5 6 |
# File 'lib/morpho/grape/data_parser.rb', line 4 def wrapper @wrapper end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/morpho/grape/data_parser.rb', line 12 def call memo = {} name = endpoint.send(:expose_params_from_model, wrapper.model) memo[wrapper.key] = if wrapper.is_array { type: :array, items: { '$ref' => "#/definitions/#{name}" } } else { type: :object, '$ref' => "#/definitions/#{name}" } end memo end |