Class: Google::DummyClient
- Inherits:
-
Object
- Object
- Google::DummyClient
- Defined in:
- lib/google/dummy_client.rb
Defined Under Namespace
Classes: UndefinedAPIError
Constant Summary collapse
- APIS =
{ "directory_v1" => { "admin" => { "schemas" => %W(insert patch update delete get), "users" => %W(insert patch delete get), }, }, "v3" => { "calendar" => { "events" => %W(insert update delete get), }, }, }.freeze
Instance Method Summary collapse
- #discovered_api(api, version) ⇒ Object
- #execute(params) ⇒ Object (also: #execute!)
-
#initialize ⇒ DummyClient
constructor
A new instance of DummyClient.
Constructor Details
#initialize ⇒ DummyClient
Returns a new instance of DummyClient.
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/google/dummy_client.rb', line 21 def initialize @class_cache = {} APIS.each do |version, stubs| stubs.each do |api, resources| cache_key = "#{api}::#{version}" @class_cache[cache_key] = DummyAPIFactory.new(api, version, APIS.fetch(version).fetch(api)) end end end |
Instance Method Details
#discovered_api(api, version) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/google/dummy_client.rb', line 32 def discovered_api(api, version) cache_key = "#{api}::#{version}" @class_cache.fetch(cache_key) rescue KeyError raise UndefinedAPIError, " The \#{api} API for version \#{version} is not stubbed out.\n See Google::DummyClient::APIS to see available API stubs.\n MSG\nend\n" |
#execute(params) ⇒ Object Also known as: execute!
42 43 44 |
# File 'lib/google/dummy_client.rb', line 42 def execute(params) OpenStruct.new(data: OpenStruct.new(params)) end |