Class: CustomHttpHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/rally_rest_api/custom_http_header.rb

Constant Summary collapse

HTTP_HEADER_FIELDS =
[:name, :vendor, :version, :library, :platform, :os]
HTTP_HEADER_PREFIX =
'X-RallyIntegration'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCustomHttpHeader

Returns a new instance of CustomHttpHeader.



8
9
10
11
12
13
# File 'lib/rally_rest_api/custom_http_header.rb', line 8

def initialize
  @os = RUBY_PLATFORM
  @platform = "Ruby #{RUBY_VERSION}"
  @library = "RallyRestAPI version #{RallyRestVersion::LIBRARY_VERSION::STRING}"
  @name = "RubyRestAPI"
end

Instance Attribute Details

#libraryObject (readonly)

Returns the value of attribute library.



3
4
5
# File 'lib/rally_rest_api/custom_http_header.rb', line 3

def library
  @library
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/rally_rest_api/custom_http_header.rb', line 2

def name
  @name
end

#osObject (readonly)

Returns the value of attribute os.



3
4
5
# File 'lib/rally_rest_api/custom_http_header.rb', line 3

def os
  @os
end

#platformObject (readonly)

Returns the value of attribute platform.



3
4
5
# File 'lib/rally_rest_api/custom_http_header.rb', line 3

def platform
  @platform
end

#vendorObject

Returns the value of attribute vendor.



2
3
4
# File 'lib/rally_rest_api/custom_http_header.rb', line 2

def vendor
  @vendor
end

#versionObject

Returns the value of attribute version.



2
3
4
# File 'lib/rally_rest_api/custom_http_header.rb', line 2

def version
  @version
end

Instance Method Details

#add_headers(req) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/rally_rest_api/custom_http_header.rb', line 15

def add_headers(req)
  headers = {}
  HTTP_HEADER_FIELDS.each do |field|
    value = self.send(field)
    next if value.nil?
    req.add_field("#{HTTP_HEADER_PREFIX}#{field.to_s.capitalize}", value)
  end
end