Class: MockServer::HttpTemplate
- Inherits:
-
Object
- Object
- MockServer::HttpTemplate
- Defined in:
- lib/mockserver/models.rb
Instance Attribute Summary collapse
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#primary ⇒ Object
Returns the value of attribute primary.
-
#template ⇒ Object
Returns the value of attribute template.
-
#template_type ⇒ Object
Returns the value of attribute template_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(template_type: 'JAVASCRIPT', template: nil, delay: nil, primary: nil) ⇒ HttpTemplate
constructor
A new instance of HttpTemplate.
- #to_h ⇒ Object
Constructor Details
#initialize(template_type: 'JAVASCRIPT', template: nil, delay: nil, primary: nil) ⇒ HttpTemplate
Returns a new instance of HttpTemplate.
794 795 796 797 798 799 |
# File 'lib/mockserver/models.rb', line 794 def initialize(template_type: 'JAVASCRIPT', template: nil, delay: nil, primary: nil) @template_type = template_type @template = template @delay = delay @primary = primary end |
Instance Attribute Details
#delay ⇒ Object
Returns the value of attribute delay.
792 793 794 |
# File 'lib/mockserver/models.rb', line 792 def delay @delay end |
#primary ⇒ Object
Returns the value of attribute primary.
792 793 794 |
# File 'lib/mockserver/models.rb', line 792 def primary @primary end |
#template ⇒ Object
Returns the value of attribute template.
792 793 794 |
# File 'lib/mockserver/models.rb', line 792 def template @template end |
#template_type ⇒ Object
Returns the value of attribute template_type.
792 793 794 |
# File 'lib/mockserver/models.rb', line 792 def template_type @template_type end |
Class Method Details
.from_hash(data) ⇒ Object
810 811 812 813 814 815 816 817 818 819 |
# File 'lib/mockserver/models.rb', line 810 def self.from_hash(data) return nil if data.nil? new( template_type: data.fetch('templateType', 'JAVASCRIPT'), template: data['template'], delay: Delay.from_hash(data['delay']), primary: data['primary'] ) end |
.template(template_type, template = nil) ⇒ Object
821 822 823 |
# File 'lib/mockserver/models.rb', line 821 def self.template(template_type, template = nil) new(template_type: template_type, template: template) end |
Instance Method Details
#to_h ⇒ Object
801 802 803 804 805 806 807 808 |
# File 'lib/mockserver/models.rb', line 801 def to_h MockServer.strip_none({ 'templateType' => @template_type, 'template' => @template, 'delay' => @delay&.to_h, 'primary' => @primary }) end |