Class: Candies::Server::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/candies/server/base.rb

Direct Known Subclasses

Gif, Json

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(responders = {}) ⇒ Base

Returns a new instance of Base.



6
7
8
# File 'lib/candies/server/base.rb', line 6

def initialize(responders = {})
  @responders = responders
end

Instance Attribute Details

#id=(value) ⇒ Object

Sets the attribute id

Parameters:

  • value

    the value to set the attribute id to.



4
5
6
# File 'lib/candies/server/base.rb', line 4

def id=(value)
  @id = value
end

#requestObject

Returns the value of attribute request.



4
5
6
# File 'lib/candies/server/base.rb', line 4

def request
  @request
end

#respondersObject

Returns the value of attribute responders.



4
5
6
# File 'lib/candies/server/base.rb', line 4

def responders
  @responders
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
# File 'lib/candies/server/base.rb', line 10

def call(env)
  @request = Rack::Request.new(env)
  @responders.fetch(format) {@responders[:json]}.call(env)
end