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.
814 815 816 817 818 819 |
# File 'lib/mockserver/models.rb', line 814 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.
812 813 814 |
# File 'lib/mockserver/models.rb', line 812 def delay @delay end |
#primary ⇒ Object
Returns the value of attribute primary.
812 813 814 |
# File 'lib/mockserver/models.rb', line 812 def primary @primary end |
#template ⇒ Object
Returns the value of attribute template.
812 813 814 |
# File 'lib/mockserver/models.rb', line 812 def template @template end |
#template_type ⇒ Object
Returns the value of attribute template_type.
812 813 814 |
# File 'lib/mockserver/models.rb', line 812 def template_type @template_type end |
Class Method Details
.from_hash(data) ⇒ Object
830 831 832 833 834 835 836 837 838 839 |
# File 'lib/mockserver/models.rb', line 830 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
841 842 843 |
# File 'lib/mockserver/models.rb', line 841 def self.template(template_type, template = nil) new(template_type: template_type, template: template) end |
Instance Method Details
#to_h ⇒ Object
821 822 823 824 825 826 827 828 |
# File 'lib/mockserver/models.rb', line 821 def to_h MockServer.strip_none({ 'templateType' => @template_type, 'template' => @template, 'delay' => @delay&.to_h, 'primary' => @primary }) end |