Class: Mingle::MingleServiceResponse

Inherits:
BitGirder::Core::BitGirderClass show all
Defined in:
lib/mingle.rb

Constant Summary

Constants included from BitGirder::Core::BitGirderMethods

BitGirder::Core::BitGirderMethods::PARAM_TYPE_ARG, BitGirder::Core::BitGirderMethods::PARAM_TYPE_ENVVAR, BitGirder::Core::BitGirderMethods::PARAM_TYPE_KEY

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BitGirder::Core::BitGirderMethods

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 BitGirder::Core::BitGirderStructure

#==, included

Constructor Details

#initialize(res, ex) ⇒ MingleServiceResponse

Returns a new instance of MingleServiceResponse.



2863
2864
2865
2866
2867
# File 'lib/mingle.rb', line 2863

def initialize( res, ex )

    @res = res
    @ex = ex
end

Class Method Details

.create_failure(ex) ⇒ Object



2923
2924
2925
# File 'lib/mingle.rb', line 2923

def self.create_failure( ex )
    MingleServiceResponse.new( nil, ex )
end

.create_success(res) ⇒ Object



2915
2916
2917
2918
2919
2920
2921
# File 'lib/mingle.rb', line 2915

def self.create_success( res )

    res = MingleModels.as_mingle_value( res );
    res = nil if res.is_a?( MingleNull )

    MingleServiceResponse.new( res, nil )
end

Instance Method Details

#getObject



2877
2878
2879
2880
2881
2882
2883
2884
# File 'lib/mingle.rb', line 2877

def get

    if ok?
        @res
    else
        MingleModels.raise_as_ruby_error( @ex )
    end
end

#get_errorObject Also known as: error



2899
2900
2901
2902
2903
2904
2905
2906
# File 'lib/mingle.rb', line 2899

def get_error
    
    if ok?
        raise "get_error called on ok response"
    else
        @ex
    end
end

#get_resultObject Also known as: result



2887
2888
2889
2890
2891
2892
2893
2894
# File 'lib/mingle.rb', line 2887

def get_result

    if ok?
        @res
    else
        raise "get_res called on non-ok response"
    end
end

#ok?Boolean Also known as: is_ok

Returns:

  • (Boolean)


2870
2871
2872
# File 'lib/mingle.rb', line 2870

def ok?
    ! @ex
end

#to_sObject



2911
2912
2913
# File 'lib/mingle.rb', line 2911

def to_s
    super.inspect
end