Module: Protoplasm::Types::ClassMethods
- Defined in:
- lib/protoplasm/types/types.rb
Instance Method Summary collapse
- #request_class(request_class = nil) ⇒ Object
- #request_type(request_obj) ⇒ Object
- #request_type_field(field = nil) ⇒ Object
- #request_type_for_field(field) ⇒ Object
- #request_type_for_request(req) ⇒ Object
- #rpc_map(type, field, response_class, opts = nil) ⇒ Object
Instance Method Details
#request_class(request_class = nil) ⇒ Object
50 51 52 |
# File 'lib/protoplasm/types/types.rb', line 50 def request_class(request_class = nil) request_class ? @request_class = request_class : @request_class end |
#request_type(request_obj) ⇒ Object
54 55 56 |
# File 'lib/protoplasm/types/types.rb', line 54 def request_type(request_obj) request_obj.send(@request_type_field) end |
#request_type_field(field = nil) ⇒ Object
58 59 60 |
# File 'lib/protoplasm/types/types.rb', line 58 def request_type_field(field = nil) field ? @request_type_field = field : @request_type_field end |
#request_type_for_field(field) ⇒ Object
71 72 73 |
# File 'lib/protoplasm/types/types.rb', line 71 def request_type_for_field(field) @response_map_by_field[field] end |
#request_type_for_request(req) ⇒ Object
75 76 77 |
# File 'lib/protoplasm/types/types.rb', line 75 def request_type_for_request(req) @response_map_by_type[req.send(@request_type_field)] end |
#rpc_map(type, field, response_class, opts = nil) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/protoplasm/types/types.rb', line 62 def rpc_map(type, field, response_class, opts = nil) @response_map_by_field ||= {} @response_map_by_type ||= {} streaming = opts && opts.key?(:streaming) ? opts[:streaming] : false rrt = RequestResponseType.new(@request_class, response_class, type, field, streaming) @response_map_by_field[field] = rrt @response_map_by_type[type] = rrt end |