Class: Cistern::Request
- Inherits:
-
Object
- Object
- Cistern::Request
- Defined in:
- lib/cistern/request.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
(also: #service)
readonly
Returns the value of attribute connection.
Class Method Summary collapse
- .register(service, klass, method) ⇒ Object
- .service(klass, options = {}) ⇒ Object
- .service_method ⇒ Object
Instance Method Summary collapse
- #_mock(*args, &block) ⇒ Object
- #_real(*args, &block) ⇒ Object
-
#initialize(connection) ⇒ Request
constructor
A new instance of Request.
- #mock(*args, &block) ⇒ Object
- #real(*args, &block) ⇒ Object
Constructor Details
#initialize(connection) ⇒ Request
Returns a new instance of Request.
22 23 24 |
# File 'lib/cistern/request.rb', line 22 def initialize(connection) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly) Also known as: service
Returns the value of attribute connection.
18 19 20 |
# File 'lib/cistern/request.rb', line 18 def connection @connection end |
Class Method Details
.register(service, klass, method) ⇒ Object
2 3 4 |
# File 'lib/cistern/request.rb', line 2 def self.register(service, klass, method) service.requests << [method, {class: klass, method: method, new: true}] end |
.service(klass, options = {}) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/cistern/request.rb', line 6 def self.service(klass, ={}) @service = klass @service_method = [:method] || Cistern::String.underscore( Cistern::String.demodulize(self.name) ) Cistern::Request.register(klass, self, @service_method) end |
.service_method ⇒ Object
14 15 16 |
# File 'lib/cistern/request.rb', line 14 def self.service_method @service_method end |
Instance Method Details
#_mock(*args, &block) ⇒ Object
30 31 32 |
# File 'lib/cistern/request.rb', line 30 def _mock(*args, &block) mock(*args, &block) end |
#_real(*args, &block) ⇒ Object
26 27 28 |
# File 'lib/cistern/request.rb', line 26 def _real(*args, &block) real(*args, &block) end |
#mock(*args, &block) ⇒ Object
38 39 40 |
# File 'lib/cistern/request.rb', line 38 def mock(*args, &block) Cistern::Mock.not_implemented(self.class.service_method) end |
#real(*args, &block) ⇒ Object
34 35 36 |
# File 'lib/cistern/request.rb', line 34 def real(*args, &block) raise NotImplementedError end |