Class: TheBigDB::StatementRequest
- Inherits:
-
Object
- Object
- TheBigDB::StatementRequest
- Defined in:
- lib/thebigdb/resources/statement.rb
Overview
Beautified builder
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#initialize(action) ⇒ StatementRequest
constructor
A new instance of StatementRequest.
- #inspect ⇒ Object
- #load ⇒ Object (also: #response, #execute)
-
#load! ⇒ Object
(also: #execute!)
forces the request to be re-loadd.
- #method_missing(method_name, *arguments, &block) ⇒ Object
- #with(params = {}) ⇒ Object
Constructor Details
#initialize(action) ⇒ StatementRequest
Returns a new instance of StatementRequest.
16 17 18 19 20 |
# File 'lib/thebigdb/resources/statement.rb', line 16 def initialize(action) @action = action @params = {} @response = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
28 29 30 31 |
# File 'lib/thebigdb/resources/statement.rb', line 28 def method_missing(method_name, *arguments, &block) @response ||= TheBigDB::Statement(@action, @params).response @response.send(method_name, *arguments, &block) end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
14 15 16 |
# File 'lib/thebigdb/resources/statement.rb', line 14 def action @action end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
14 15 16 |
# File 'lib/thebigdb/resources/statement.rb', line 14 def params @params end |
Instance Method Details
#inspect ⇒ Object
45 46 47 |
# File 'lib/thebigdb/resources/statement.rb', line 45 def inspect load.inspect end |
#load ⇒ Object Also known as: response, execute
33 34 35 |
# File 'lib/thebigdb/resources/statement.rb', line 33 def load to_hash # goes through method_missing end |
#load! ⇒ Object Also known as: execute!
forces the request to be re-loadd
39 40 41 42 |
# File 'lib/thebigdb/resources/statement.rb', line 39 def load! # forces the request to be re-loadd @response = nil to_hash end |
#with(params = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/thebigdb/resources/statement.rb', line 22 def with(params = {}) @response = nil @params.merge!(TheBigDB::Helpers::stringify_keys(params)) self end |