Module: AvroTurf::Test::FakeServer::ClassMethods

Defined in:
lib/avro_turf/test/fake_server.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

Rack interface - creates a new instance and calls it



86
87
88
# File 'lib/avro_turf/test/fake_server.rb', line 86

def call(env)
  new.call(env)
end

#delete(pattern, &block) ⇒ Object

Define a DELETE route



66
67
68
# File 'lib/avro_turf/test/fake_server.rb', line 66

def delete(pattern, &block)
  add_route("DELETE", pattern, block)
end

#get(pattern, &block) ⇒ Object

Define a GET route



51
52
53
# File 'lib/avro_turf/test/fake_server.rb', line 51

def get(pattern, &block)
  add_route("GET", pattern, block)
end

#host_authorizationObject

Access host authorization settings



81
82
83
# File 'lib/avro_turf/test/fake_server.rb', line 81

def host_authorization
  @host_authorization
end

#inherited(subclass) ⇒ Object

When a class inherits from another that includes FakeServer, ensure it gets its own routes hash



45
46
47
48
# File 'lib/avro_turf/test/fake_server.rb', line 45

def inherited(subclass)
  super
  subclass.instance_variable_set(:@routes, nil)
end

#post(pattern, &block) ⇒ Object

Define a POST route



56
57
58
# File 'lib/avro_turf/test/fake_server.rb', line 56

def post(pattern, &block)
  add_route("POST", pattern, block)
end

#put(pattern, &block) ⇒ Object

Define a PUT route



61
62
63
# File 'lib/avro_turf/test/fake_server.rb', line 61

def put(pattern, &block)
  add_route("PUT", pattern, block)
end

#routesObject

Storage for routes defined in this class



39
40
41
# File 'lib/avro_turf/test/fake_server.rb', line 39

def routes
  @routes ||= {"GET" => [], "POST" => [], "PUT" => [], "DELETE" => []}
end

#set(key, value) ⇒ Object

Sinatra-compatible ‘set` method for configuration



71
72
73
74
75
76
77
78
# File 'lib/avro_turf/test/fake_server.rb', line 71

def set(key, value)
  case key
  when :host_authorization
    @host_authorization = value
  else
    instance_variable_set(:"@#{key}", value)
  end
end