-
Notifications
You must be signed in to change notification settings - Fork 741
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Code changes to generate resources/subresources (#1769)
Code changes to generate resources/subresources in ruby based on the standard definitions defined in MSRestAzure
- Loading branch information
1 parent
5788a5f
commit 1fae9ec
Showing
4 changed files
with
135 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/generator/AutoRest.Ruby.Azure/Templates/AzureModelTemplate.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@using System | ||
@using System.Linq | ||
@using AutoRest.Core.Utilities | ||
@using AutoRest.Ruby | ||
@using AutoRest.Ruby.Model | ||
@using AutoRest.Ruby.Azure.Model | ||
@inherits AutoRest.Core.Template<AutoRest.Ruby.Model.CompositeTypeRb> | ||
# encoding: utf-8 | ||
@Header("# ") | ||
@EmptyLine | ||
module @(Settings.Namespace) | ||
module Models | ||
# | ||
@WrapComment("# ", Model.BuildSummaryAndDescriptionString()) | ||
# | ||
class @Model.Name@(Model.GetBaseTypeName()) | ||
@if (Model.Includes.Any()) | ||
{ | ||
@EmptyLine | ||
foreach (var include in Model.Includes) | ||
{ | ||
@:include @include | ||
} | ||
@EmptyLine | ||
} | ||
|
||
@if (Model.BaseIsPolymorphic && Model.BaseModelType == null) | ||
{ | ||
@:@@@@discriminatorMap = Hash.new | ||
foreach (var derivedType in Model.DerivedTypes) | ||
{ | ||
@:@@@@discriminatorMap["@derivedType.SerializedName"] = "@derivedType.Name" | ||
} | ||
} | ||
|
||
@if (Model.BaseIsPolymorphic) | ||
{ | ||
@EmptyLine | ||
@:def initialize | ||
@: @@@Model.PolymorphicDiscriminatorProperty.Name = "@Model.SerializedName" | ||
@:end | ||
@EmptyLine | ||
@:attr_accessor :@Model.PolymorphicDiscriminatorProperty.Name | ||
@EmptyLine | ||
} | ||
|
||
@foreach (var property in Model.PropertyTemplateModels.Where(each => !each.IsPolymorphicDiscriminator)) | ||
{ | ||
@if (CompositeTypeRba.NeedsAccessor(Model, property.Name)) | ||
{ | ||
@:@WrapComment("# ", string.Format("@return {0}{1}", property.ModelType.GetYardDocumentation(), CompositeTypeRb.GetPropertyDocumentationString(property))) | ||
@:attr_accessor :@property.Name | ||
@EmptyLine | ||
@: | ||
} | ||
} | ||
|
||
@EmptyLine | ||
# | ||
@WrapComment("# ", string.Format("Mapper for {0} class as Ruby Hash.", Model.Name)) | ||
# This will be used for serialization/deserialization. | ||
# | ||
def self.mapper() | ||
@(Model.ConstructModelMapper()) | ||
end | ||
end | ||
end | ||
end |