ruby.model.mustache Maven / Gradle / Ivy
{{#models}}
{{#model}}
class {{classname}}
attr_accessor {{#vars}}:{{{name}}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{newline}}
# :internal => :external
def self.attribute_map
{
{{#vars}}
:{{{name}}} => :{{{baseName}}}{{#hasMore}},
{{/hasMore}}
{{/vars}}{{newline}}
}
end
def initialize(attributes = {})
return if attributes.empty?
# Morph attribute keys into undescored rubyish style
{{#vars}}
if self.class.attribute_map[:"{{{name}}}"]
{{#isContainer}}
if (value = attributes["{{{baseName}}}"]).is_a?(Array)
@{{{name}}} = value{{#complexType}}.map{ |v| {{complexType}}.new(v) }{{/complexType}}
end
{{/isContainer}}{{^isContainer}}
@{{{name}}} = attributes["{{{baseName}}}"]
{{/isContainer}}
end
{{/vars}}{{newline}}
end
def to_body
body = {}
self.class.attribute_map.each_pair do |key, value|
body[value] = self.send(key) unless self.send(key).nil?
end
body
end
end
{{/model}}
{{/models}}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy