Module: Mingle::Service::MingleServices
Constant Summary
collapse
- TYPE_SERVICE_REQUEST =
MingleTypeReference.get( :"service@v1/ServiceRequest" )
- TYPE_SERVICE_RESPONSE =
MingleTypeReference.get( :"service@v1/ServiceResponse" )
BitGirder::Core::BitGirderMethods::PARAM_TYPE_ARG, BitGirder::Core::BitGirderMethods::PARAM_TYPE_ENVVAR, BitGirder::Core::BitGirderMethods::PARAM_TYPE_KEY
Constants included
from Mingle
COMPARABLE_TYPES, ID_STYLES, ID_STYLE_LC_CAMEL_CAPPED, ID_STYLE_LC_HYPHENATED, ID_STYLE_LC_UNDERSCORE, INT_TYPES, NUM_TYPES, PARSED_TYPES, QNAME_RESOLV_MAP, USE_ICONV
Class Method Summary
collapse
argv_to_argh, check_fail_prefix, class_name_to_sym, code, compares_to, console, ext_to_class_name, ext_to_sym, has_env, has_key, has_keys, nonnegative, not_nil, positive, raisef, set_from_key, set_var, split_argv, sym_to_cli_switch, sym_to_ext_id, to_bool, unpack_argv_array, unpack_argv_hash, warn
Methods included from Mingle
cast_value, quote_value
Class Method Details
.as_mingle_struct(obj) ⇒ Object
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/mingle/service.rb', line 55
def as_mingle_struct( obj )
not_nil( obj, :obj )
case obj
when MingleServiceRequest then from_svc_req( obj )
when MingleServiceResponse then from_svc_resp( obj )
else raise "Can't convert to mingle struct: #{obj}"
end
end
|
.as_service_request(ms) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/mingle/service.rb', line 66
def as_service_request( ms )
not_nil( ms, :ms )
check_type( ms, TYPE_SERVICE_REQUEST, "service request" )
f = ms.fields
MingleServiceRequest.new(
:namespace => MingleNamespace.get( f.expect_string( :namespace ) ),
:service => MingleIdentifier.get( f.expect_string( :service ) ),
:operation => MingleIdentifier.get( f.expect_string( :operation ) ),
:parameters => f[ :parameters ],
:authentication => f[ :authentication ]
)
end
|
.as_service_response(ms) ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
# File 'lib/mingle/service.rb', line 90
def as_service_response( ms )
not_nil( ms, :ms )
check_type( ms, TYPE_SERVICE_RESPONSE, "service response" )
ex = get_non_nil( ms[ :exception ] )
res = get_non_nil( ms[ :result ] )
( ex == nil || res == nil ) or
raise "Response has non-nil result and exception"
if ex
MingleServiceResponse.create_failure( ex )
else
MingleServiceResponse.create_success( res )
end
end
|
.check_type(ms, typ_expct, err_type) ⇒ Object
20
21
22
23
24
|
# File 'lib/mingle/service.rb', line 20
def check_type( ms, typ_expct, err_type )
( typ = ms.type ) == typ_expct or
raise "Invalid #{err_type} type: #{typ}"
end
|
.from_svc_req(req) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/mingle/service.rb', line 26
def from_svc_req( req )
flds = {
:namespace => req.namespace.external_form,
:service => req.service.external_form,
:operation => req.operation.external_form
}
if ( ( val = req.parameters ) && ( ! val.empty? ) )
flds[ :parameters ] = val
end
if ( val = req.authentication ) then flds[ :authentication ] = val end
MingleStruct.new( :type => TYPE_SERVICE_REQUEST, :fields => flds )
end
|
.from_svc_resp(resp) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/mingle/service.rb', line 43
def from_svc_resp( resp )
flds =
if resp.ok?
resp.result ? { :result => resp.result } : {}
else
{ :exception => resp.error }
end
MingleStruct.new( :type => TYPE_SERVICE_RESPONSE, :fields => flds )
end
|
.get_non_nil(val) ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/mingle/service.rb', line 82
def get_non_nil( val )
case val
when MingleNull then nil
else val
end
end
|