Module: Webbed::Helpers::EntityHeadersHelper

Included in:
Request, Response
Defined in:
lib/webbed/helpers/entity_headers_helper.rb

Overview

Request and Response helper for Entity Headers

Instance Method Summary (collapse)

Instance Method Details

- (<Webbed::Method>?) allowed_methods

The allowed Methods of the Entity (as defined in the Allow Header).

Returns:



64
65
66
67
68
69
70
71
72
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 64

def allowed_methods
  if headers['Allow']
    headers['Allow'].split(/\s*,\s*/).map do |method|
      Webbed::Method.lookup(method)
    end
  else
    nil
  end
end

- allowed_methods=(allowed_methods)

Sets the allowed Methods of the Entity (as defined in the Allow Header).

Parameters:

  • (<#to_s>)


77
78
79
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 77

def allowed_methods=(allowed_methods)
  headers['Allow'] = allowed_methods.join(', ')
end

- (Fixnum?) content_length

The Content-Length of the Entity (as defined in the Content-Length Header).

Returns:

  • (Fixnum, nil)


8
9
10
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 8

def content_length
  headers['Content-Length'] ? headers['Content-Length'].to_i : nil
end

- content_length=(content_length)

Sets the Content-Length of the Entity (as defined in the Content-Length Header).

Parameters:

  • content_length (#to_s)


15
16
17
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 15

def content_length=(content_length)
  headers['Content-Length'] = content_length.to_s
end

- (Addressable::URI?) content_location

The Content-Location of the Entity (as defined in the Content-Location Header).

Returns:

  • (Addressable::URI, nil)


22
23
24
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 22

def content_location
  headers['Content-Location'] ? Addressable::URI.parse(headers['Content-Location']) : nil
end

- content_location=(content_location)

Sets the Content-Location of the Entity (as defined in the Content-Location Header).

Parameters:

  • content_location (#to_s)


29
30
31
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 29

def content_location=(content_location)
  headers['Content-Location'] = content_location.to_s
end

- (String?) content_md5

The Content-MD5 of the Entity (as defined in the Content-MD5 Header).

Returns:

  • (String, nil)


36
37
38
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 36

def content_md5
  headers['Content-MD5']
end

- content_md5=(content_md5)

Sets the Content-MD5 of the Entity (as defined in the Content-MD5 Header).

Parameters:

  • content_md5 (String)


43
44
45
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 43

def content_md5=(content_md5)
  headers['Content-MD5'] = content_md5
end

- (Webbed::MediaType?) content_type

The Content-Type of the Entity (as defined in the Content-Type Header).

Returns:



50
51
52
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 50

def content_type
  headers['Content-Type'] ? Webbed::MediaType.new(headers['Content-Type']) : nil
end

- content_type=(content_type)

Sets the Content-Type of the Entity (as defined in the Content-Type Header).

Parameters:

  • content_type (#to_s)


57
58
59
# File 'lib/webbed/helpers/entity_headers_helper.rb', line 57

def content_type=(content_type)
  headers['Content-Type'] = content_type.to_s
end