regal 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,23 @@
1
1
  module Regal
2
2
  class Response
3
+ # @!attribute [rw] status
4
+ # @return [Hash]
5
+
6
+ # @!attribute [rw] body
7
+ # @return [Object]
8
+
9
+ # @!attribute [rw] raw_body
10
+ # @return [Enumerable]
11
+
12
+ # @!attribute [r] headers
13
+ # @return [Hash]
14
+
3
15
  attr_accessor :status, :body, :raw_body
4
16
  attr_reader :headers
5
17
 
6
18
  EMPTY_BODY = [].freeze
7
19
 
20
+ # @private
8
21
  def initialize
9
22
  @status = 200
10
23
  @headers = {}
@@ -13,18 +26,23 @@ module Regal
13
26
  @finished = false
14
27
  end
15
28
 
29
+ # @return [void]
16
30
  def finish
17
31
  @finished = true
18
32
  end
19
33
 
34
+ # @return [true, false]
20
35
  def finished?
21
36
  @finished
22
37
  end
23
38
 
39
+ # @return [Array<()>]
24
40
  def no_body
25
41
  @raw_body = EMPTY_BODY
26
42
  end
27
43
 
44
+ # @param [Integer] n
45
+ # @return [Integer, Hash, Enumerable]
28
46
  def [](n)
29
47
  case n
30
48
  when 0 then @status
@@ -33,6 +51,9 @@ module Regal
33
51
  end
34
52
  end
35
53
 
54
+ # @param [Integer] n
55
+ # @param [Integer, Hash, Enumerable] v
56
+ # @return [Integer, Hash, Enumerable]
36
57
  def []=(n, v)
37
58
  case n
38
59
  when 0 then @status = v
@@ -41,6 +62,7 @@ module Regal
41
62
  end
42
63
  end
43
64
 
65
+ # @return [Array<(Integer, Hash, Enumerable)>]
44
66
  def to_ary
45
67
  [@status, @headers, rack_body]
46
68
  end
@@ -53,6 +75,8 @@ module Regal
53
75
  @raw_body
54
76
  elsif @body.is_a?(String)
55
77
  [@body]
78
+ elsif @body.nil?
79
+ EMPTY_BODY
56
80
  else
57
81
  @body
58
82
  end
data/lib/regal/version.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Regal
2
- VERSION = '0.1.0'.freeze
2
+ # @private
3
+ VERSION = '0.2.0'.freeze
3
4
  end