Class: ApiMaker::ModelContentGeneratorService

Inherits:
ApplicationService
  • Object
show all
Defined in:
app/services/api_maker/model_content_generator_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationService

#api_maker_json

Constructor Details

#initialize(model:) ⇒ ModelContentGeneratorService

Returns a new instance of ModelContentGeneratorService.



4
5
6
# File 'app/services/api_maker/model_content_generator_service.rb', line 4

def initialize(model:)
  @model = model
end

Instance Attribute Details

#modelObject (readonly)

Returns the value of attribute model.



2
3
4
# File 'app/services/api_maker/model_content_generator_service.rb', line 2

def model
  @model
end

Instance Method Details

#executeObject



8
9
10
11
12
13
14
# File 'app/services/api_maker/model_content_generator_service.rb', line 8

def execute
  if resource
    ServicePattern::Response.new(result: model_content)
  else
    ServicePattern::Response.new(errors: ["No resource defined for #{model.name}"])
  end
end