class Rohbau::Interface
Public Class Methods
new()
click to toggle source
# File lib/rohbau/interface.rb, line 10 def initialize @calls = Hash.new { |h, k| h[k] = nil } @call_count = Hash.new { |h, k| h[k] = 0 } @stub_results = Hash.new { |h, k| h[k] = nil } @stub_type_for = Hash.new { |h, k| h[k] = nil } end
Public Instance Methods
call_count()
click to toggle source
# File lib/rohbau/interface.rb, line 32 def call_count @call_count end
calls()
click to toggle source
# File lib/rohbau/interface.rb, line 28 def calls @calls end
clear_cached_requests()
click to toggle source
# File lib/rohbau/interface.rb, line 24 def clear_cached_requests RequestCache.clear end
clear_stubs()
click to toggle source
# File lib/rohbau/interface.rb, line 17 def clear_stubs calls.clear call_count.clear stub_results.clear stub_type_for.clear end
Private Instance Methods
call_use_case(domain, use_case, args)
click to toggle source
# File lib/rohbau/interface.rb, line 38 def call_use_case(domain, use_case, args) call_count[use_case] += 1 unless args.key?(:stub_result) calls[use_case] = args domain = camel_case(domain) use_case = camel_case(use_case) caller = Caller.new domain overwrite_stub_result_for(use_case, args[:stub_result]) overwrite_stub_type_for(use_case, args[:stub_type]) caller.call use_case, args, :stub_result => stub_results[use_case], :stub_type => stub_type_for[use_case] || :Success end
camel_case(sym)
click to toggle source
# File lib/rohbau/interface.rb, line 71 def camel_case(sym) sym.to_s.split('_').each(&:capitalize!).join end
method_missing(domain, *args)
click to toggle source
# File lib/rohbau/interface.rb, line 75 def method_missing(domain, *args) use_case = args[0] input = args[1] || {} call_use_case(domain, use_case, input) end
overwrite_stub_result_for(use_case, stub_result)
click to toggle source
# File lib/rohbau/interface.rb, line 53 def overwrite_stub_result_for(use_case, stub_result) return if stub_result.nil? stub_results[use_case] = stub_result end
overwrite_stub_type_for(use_case, stub_type)
click to toggle source
# File lib/rohbau/interface.rb, line 58 def overwrite_stub_type_for(use_case, stub_type) return if stub_type.nil? stub_type_for[use_case] = stub_type end
stub_results()
click to toggle source
# File lib/rohbau/interface.rb, line 63 def stub_results @stub_results end
stub_type_for()
click to toggle source
# File lib/rohbau/interface.rb, line 67 def stub_type_for @stub_type_for end