Class: OpenAPIRest::ApiModel
- Inherits:
-
Object
- Object
- OpenAPIRest::ApiModel
- Defined in:
- lib/openapi_rest/api_model.rb
Overview
Rest Api Model
Instance Attribute Summary collapse
-
#model ⇒ Object
Returns the value of attribute model.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #build(params, args = {}, &block) ⇒ Object
- #find(params, args = {}, &block) ⇒ Object
-
#initialize(type) ⇒ ApiModel
constructor
A new instance of ApiModel.
- #where(params, args = {}, &block) ⇒ Object
Constructor Details
#initialize(type) ⇒ ApiModel
Returns a new instance of ApiModel.
9 10 11 12 |
# File 'lib/openapi_rest/api_model.rb', line 9 def initialize(type) @type = type @model = type.to_s.capitalize!.constantize end |
Instance Attribute Details
#model ⇒ Object
Returns the value of attribute model.
7 8 9 |
# File 'lib/openapi_rest/api_model.rb', line 7 def model @model end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/openapi_rest/api_model.rb', line 6 def type @type end |
Instance Method Details
#build(params, args = {}, &block) ⇒ Object
14 15 16 |
# File 'lib/openapi_rest/api_model.rb', line 14 def build(params, args = {}, &block) native_query(params.merge(operation: :create), args, &block) end |
#find(params, args = {}, &block) ⇒ Object
22 23 24 |
# File 'lib/openapi_rest/api_model.rb', line 22 def find(params, args = {}, &block) native_query(params.merge(operation: :squery), args, &block) end |
#where(params, args = {}, &block) ⇒ Object
18 19 20 |
# File 'lib/openapi_rest/api_model.rb', line 18 def where(params, args = {}, &block) native_query(params.merge(operation: :query), args, &block) end |