Class: Apipony::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/apipony/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, array: false, &block) ⇒ Response

Returns a new instance of Response.



3
4
5
6
7
8
# File 'lib/apipony/response.rb', line 3

def initialize(status, array: false, &block)
  @status = status
  @attributes = []
  @array = array
  instance_eval(&block) if block_given?
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



2
3
4
# File 'lib/apipony/response.rb', line 2

def attributes
  @attributes
end

#example(&block) ⇒ Object

Returns the value of attribute example.



2
3
4
# File 'lib/apipony/response.rb', line 2

def example
  @example
end

#statusObject

Returns the value of attribute status.



2
3
4
# File 'lib/apipony/response.rb', line 2

def status
  @status
end

Instance Method Details

#attribute(name, **params, &block) ⇒ Object



22
23
24
25
26
27
# File 'lib/apipony/response.rb', line 22

def attribute(name, **params, &block)
  if params[:example]
    @use_attribute_examples = true
  end
  @attributes << Apipony::ResponseAttribute.new(name, **params, &block)
end

#is_array?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/apipony/response.rb', line 10

def is_array?
  !! @array
end