class TeamCity::Headers
Constants
- VALID_FORMATS
Attributes
accept[RW]
content_type[RW]
Public Class Methods
build(opts={})
click to toggle source
# File lib/teamcity/headers.rb, line 6 def self.build(opts={}) accept_format = opts.fetch(:accept){ :json } content_type_format = opts.fetch(:content_type){ :json } raise ArgumentError, "Invalid format for :accept, valid formats: #{VALID_FORMATS}" unless VALID_FORMATS.include?(accept_format) raise ArgumentError, "Invalid format for :content_type, valid format: #{VALID_FORMATS}" unless VALID_FORMATS.include?(content_type_format) new do |headers| headers.accept = self.const_get(accept_format.to_s.capitalize).accept headers.content_type = self.const_get(content_type_format.to_s.capitalize).content_type end end
new() { |self| ... }
click to toggle source
# File lib/teamcity/headers.rb, line 19 def initialize yield(self) if block_given? end
Public Instance Methods
to_hash()
click to toggle source
# File lib/teamcity/headers.rb, line 23 def to_hash { 'Accept' => accept, 'Content-Type' => content_type } end