rubygarage / api_struct

API wrapper builder with response serialization
MIT License
234 stars 21 forks source link

Can't use multiple clients without prefixes #14

Open SteveRedka opened 4 years ago

SteveRedka commented 4 years ago

Currently if you try to use multiple clients in same entity, entity will define methods only from the latest client. As in:

class StubClient < ApiStruct::Client
  def foo
    # do something
  end
end

class AnotherStubClient < ApiStruct::Client
  def bar
    # do something
  end
end

  class StubEntity < ApiStruct::Entity
    client_service StubClient
    client_service AnotherStubClient
  end

It will complain:

> StubEntity.foo
NoMethodError:
  undefined method `foo' for #<AnotherStubClient:0x00000000019128e0>

See also: https://github.com/rubygarage/api_struct/issues/13