Class: Alf::Rest::Test::Client
- Inherits:
-
Object
- Object
- Alf::Rest::Test::Client
- Includes:
- Payload::Client, Rack::Test::Methods
- Defined in:
- lib/alf/rest/test/client.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#db_conn ⇒ Object
readonly
Returns the value of attribute db_conn.
-
#global_headers ⇒ Object
Returns the value of attribute global_headers.
-
#global_parameters ⇒ Object
Returns the value of attribute global_parameters.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
Instance Method Summary collapse
- #disconnect ⇒ Object
- #global_header(k, v) ⇒ Object
- #headers ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #parameter(k, v) ⇒ Object
- #reset ⇒ Object
- #with_database {|database| ... } ⇒ Object
- #with_db_conn {|db_conn| ... } ⇒ Object
- #with_relvar(*args, &bl) ⇒ Object
Methods included from Payload::Client
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
8 9 10 11 12 13 14 15 |
# File 'lib/alf/rest/test/client.rb', line 8 def initialize(config) @config = config @database = config.database @db_conn = config.database.connection @global_headers = { "Content-Type" => "application/json" } @global_parameters = { } reset end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
19 20 21 |
# File 'lib/alf/rest/test/client.rb', line 19 def body @body end |
#database ⇒ Object (readonly)
Returns the value of attribute database.
16 17 18 |
# File 'lib/alf/rest/test/client.rb', line 16 def database @database end |
#db_conn ⇒ Object (readonly)
Returns the value of attribute db_conn.
16 17 18 |
# File 'lib/alf/rest/test/client.rb', line 16 def db_conn @db_conn end |
#global_headers ⇒ Object
Returns the value of attribute global_headers.
18 19 20 |
# File 'lib/alf/rest/test/client.rb', line 18 def global_headers @global_headers end |
#global_parameters ⇒ Object
Returns the value of attribute global_parameters.
17 18 19 |
# File 'lib/alf/rest/test/client.rb', line 17 def global_parameters @global_parameters end |
#parameters ⇒ Object
Returns the value of attribute parameters.
20 21 22 |
# File 'lib/alf/rest/test/client.rb', line 20 def parameters @parameters end |
Instance Method Details
#disconnect ⇒ Object
28 29 30 |
# File 'lib/alf/rest/test/client.rb', line 28 def disconnect db_conn.close if db_conn end |
#global_header(k, v) ⇒ Object
50 51 52 |
# File 'lib/alf/rest/test/client.rb', line 50 def global_header(k, v) global_headers[k] = v end |
#headers ⇒ Object
46 47 48 |
# File 'lib/alf/rest/test/client.rb', line 46 def headers current_session.headers end |
#parameter(k, v) ⇒ Object
54 55 56 |
# File 'lib/alf/rest/test/client.rb', line 54 def parameter(k, v) parameters[k] = v end |
#reset ⇒ Object
22 23 24 25 26 |
# File 'lib/alf/rest/test/client.rb', line 22 def reset self.body = nil self.parameters = {} global_headers.each{|k,v| header(k,v) } end |
#with_database {|database| ... } ⇒ Object
32 33 34 |
# File 'lib/alf/rest/test/client.rb', line 32 def with_database yield(database) end |
#with_db_conn {|db_conn| ... } ⇒ Object
36 37 38 |
# File 'lib/alf/rest/test/client.rb', line 36 def with_db_conn(&bl) yield(db_conn) end |
#with_relvar(*args, &bl) ⇒ Object
40 41 42 43 44 |
# File 'lib/alf/rest/test/client.rb', line 40 def with_relvar(*args, &bl) with_db_conn do |db_conn| yield(db_conn.relvar(*args)) end end |