Class: Ghost::Response
- Inherits:
-
Object
- Object
- Ghost::Response
- Includes:
- Enumerable
- Defined in:
- lib/ghost/response.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #data ⇒ Object
- #each(&block) ⇒ Object
- #first ⇒ Object
-
#initialize(raw) ⇒ Response
constructor
A new instance of Response.
- #meta ⇒ Object
- #pagination ⇒ Object
- #to_a ⇒ Object
Constructor Details
#initialize(raw) ⇒ Response
Returns a new instance of Response.
9 10 11 |
# File 'lib/ghost/response.rb', line 9 def initialize(raw) @raw = raw end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
7 8 9 |
# File 'lib/ghost/response.rb', line 7 def raw @raw end |
Instance Method Details
#data ⇒ Object
13 14 15 |
# File 'lib/ghost/response.rb', line 13 def data @data ||= raw[resource_key] || [] end |
#each(&block) ⇒ Object
29 30 31 |
# File 'lib/ghost/response.rb', line 29 def each(&block) data.each(&block) end |
#first ⇒ Object
17 18 19 |
# File 'lib/ghost/response.rb', line 17 def first data.first end |
#meta ⇒ Object
21 22 23 |
# File 'lib/ghost/response.rb', line 21 def raw["meta"] end |
#pagination ⇒ Object
25 26 27 |
# File 'lib/ghost/response.rb', line 25 def pagination &.dig("pagination") end |
#to_a ⇒ Object
33 34 35 |
# File 'lib/ghost/response.rb', line 33 def to_a data end |