Class: OpenAPIRest::ApiModel

Inherits:
Object
  • Object
show all
Defined in:
lib/openapi_rest/api_model.rb

Overview

Rest Api Model

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#modelObject

Returns the value of attribute model.



7
8
9
# File 'lib/openapi_rest/api_model.rb', line 7

def model
  @model
end

#typeObject (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