Module: LHS::Service::Endpoints::ClassMethods

Defined in:
lib/lhs/concerns/service/endpoints.rb

Instance Method Summary collapse

Instance Method Details

#endpoint(url, options = nil) ⇒ Object

Adds the endpoint to the list of endpoints.



18
19
20
21
22
23
24
# File 'lib/lhs/concerns/service/endpoints.rb', line 18

def endpoint(url, options = nil)
  endpoint = LHC::Endpoint.new(url, options)
  instance.sanity_check(endpoint)
  instance.endpoints.push(endpoint)
  LHS::Service::Endpoints.all ||= {}
  LHS::Service::Endpoints.all[url] = instance
end

#for_url(url) ⇒ Object



26
27
28
29
30
31
# File 'lib/lhs/concerns/service/endpoints.rb', line 26

def for_url(url)
  template, service = LHS::Service::Endpoints.all.detect do |template, _service|
    LHC::Endpoint.match?(url, template)
  end
  service
end