Class: OData::Model::CLI::ModelTemplate Private
- Inherits:
-
Object
- Object
- OData::Model::CLI::ModelTemplate
- Defined in:
- lib/odata/model/cli/model_template.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents the model template used by the command-line generator.
Instance Attribute Summary collapse
- #class_name ⇒ Object readonly private
- #properties ⇒ Object readonly private
- #service_name ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(class_name, service_name, properties, entity_name) ⇒ ModelTemplate
constructor
private
A new instance of ModelTemplate.
- #render ⇒ Object private
- #template ⇒ Object private
Constructor Details
#initialize(class_name, service_name, properties, entity_name) ⇒ ModelTemplate
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ModelTemplate.
12 13 14 15 16 17 |
# File 'lib/odata/model/cli/model_template.rb', line 12 def initialize(class_name, service_name, properties, entity_name) @class_name = class_name @service_name = service_name @properties = properties @entity_name = entity_name end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/odata/model/cli/model_template.rb', line 10 def class_name @class_name end |
#properties ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/odata/model/cli/model_template.rb', line 10 def properties @properties end |
#service_name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 |
# File 'lib/odata/model/cli/model_template.rb', line 10 def service_name @service_name end |
Instance Method Details
#render ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 |
# File 'lib/odata/model/cli/model_template.rb', line 34 def render renderer = ERB.new(template, 0, '<>') renderer.result(binding) end |
#template ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/odata/model/cli/model_template.rb', line 19 def template <<-EOS class <%= @class_name %> include OData::Model use_service '<%= @service_name %>' <%= @entity_name.nil? ? nil : "use_entity_set '\#\{@entity_name\}'" %> <% properties.each do |property_name, as_name| %> property '<%= property_name %>'<%= as_name.nil? ? nil : ", as: :\#\{as_name\}" %> <% end %> end EOS end |