Class: Rack::Contrib::Sign::Receipt
- Inherits:
-
Object
- Object
- Rack::Contrib::Sign::Receipt
- Defined in:
- lib/rack/contrib/sign/receipt.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#api_secret ⇒ Object
Returns the value of attribute api_secret.
-
#body ⇒ Object
Returns the value of attribute body.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#host ⇒ Object
Returns the value of attribute host.
-
#request_method ⇒ Object
Returns the value of attribute request_method.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #body_length ⇒ Object
- #body_md5 ⇒ Object
- #header_text ⇒ Object
-
#initialize ⇒ Receipt
constructor
A new instance of Receipt.
- #preamble ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Receipt
Returns a new instance of Receipt.
15 16 17 |
# File 'lib/rack/contrib/sign/receipt.rb', line 15 def initialize @headers = {} end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/rack/contrib/sign/receipt.rb', line 8 def api_key @api_key end |
#api_secret ⇒ Object
Returns the value of attribute api_secret.
9 10 11 |
# File 'lib/rack/contrib/sign/receipt.rb', line 9 def api_secret @api_secret end |
#body ⇒ Object
Returns the value of attribute body.
10 11 12 |
# File 'lib/rack/contrib/sign/receipt.rb', line 10 def body @body end |
#content_type ⇒ Object
Returns the value of attribute content_type.
11 12 13 |
# File 'lib/rack/contrib/sign/receipt.rb', line 11 def content_type @content_type end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/rack/contrib/sign/receipt.rb', line 7 def headers @headers end |
#host ⇒ Object
Returns the value of attribute host.
13 14 15 |
# File 'lib/rack/contrib/sign/receipt.rb', line 13 def host @host end |
#request_method ⇒ Object
Returns the value of attribute request_method.
6 7 8 |
# File 'lib/rack/contrib/sign/receipt.rb', line 6 def request_method @request_method end |
#uri ⇒ Object
Returns the value of attribute uri.
12 13 14 |
# File 'lib/rack/contrib/sign/receipt.rb', line 12 def uri @uri end |
Instance Method Details
#body_length ⇒ Object
27 28 29 |
# File 'lib/rack/contrib/sign/receipt.rb', line 27 def body_length body.length end |
#body_md5 ⇒ Object
23 24 25 |
# File 'lib/rack/contrib/sign/receipt.rb', line 23 def body_md5 Digest::MD5.hexdigest(body) end |
#header_text ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/rack/contrib/sign/receipt.rb', line 47 def header_text s = "" headers.sort_by { |k,v| k.downcase }.each do |header, value| s << "%s:%s\n" % [header.downcase, value] end s end |
#preamble ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rack/contrib/sign/receipt.rb', line 35 def preamble s = "" s << "%s\n" % request_method s << "%s\n" % host s << "%s\n" % uri s << "%s\n" % api_key s << "%s\n" % content_type s << "%s\n" % body_length s << "%s\n" % body_md5 s end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/rack/contrib/sign/receipt.rb', line 31 def to_s preamble + header_text end |