Class: Kippt::CollectionResource::SaveResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/kippt/collection_resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ SaveResponse

Returns a new instance of SaveResponse.



10
11
12
# File 'lib/kippt/collection_resource.rb', line 10

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



8
9
10
# File 'lib/kippt/collection_resource.rb', line 8

def response
  @response
end

Instance Method Details

#[](key) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/kippt/collection_resource.rb', line 14

def [](key)
  return @save_response[key] if @save_response

  @save_response = {success: response.success?, resource: response.body}
  if response.body["message"]
    @save_response[:error_message] = response.body["message"]
  end

  @save_response[key]
end

#success?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/kippt/collection_resource.rb', line 25

def success?
  self[:success]
end