Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Services module #875

Merged
merged 8 commits into from
Mar 16, 2017
Merged

Introduce Services module #875

merged 8 commits into from
Mar 16, 2017

Conversation

chrisroos
Copy link
Contributor

Using a Services module to keep all the GdsApi clients together is a pattern used in a number of other GOV.UK apps.

As suggested by @h-lame.

Fixes issue #811.

@floehopper floehopper self-requested a review March 16, 2017 11:08
@floehopper floehopper self-assigned this Mar 16, 2017
Copy link
Contributor

@floehopper floehopper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether it's worth also moving the ORGANISATIONS_API_BASE_PATH constant from its initializer into the new Services module. It might be worth seeing what other applications do.

Other than that minor suggestion, this looks good to me.

This removes some duplication and will make it clearer that this needs
to change when I introduce  a `Services` module to hold the various API
clients.
Using a `Services` module to keep all the GdsApi clients together is a
pattern used in a number of other GOV.UK apps.

I'm manually requiring "services" where appropriate as the lib directory
isn't in the array of `autoload_paths`.
Using a `Services` module to keep all the GdsApi clients together is a
pattern used in a number of other GOV.UK apps.

I'm manually requiring "services" where appropriate as the lib directory
isn't in the array of `autoload_paths`.

Note that we're already requiring "services" in
abstract_manual_document_service_registry.rb so I haven't had to require
it again.
Using a `Services` module to keep all the GdsApi clients together is a
pattern used in a number of other GOV.UK apps.

I'm manually requiring "services" where appropriate as the lib directory
isn't in the array of `autoload_paths`.
Using a `Services` module to keep all the GdsApi clients together is a
pattern used in a number of other GOV.UK apps.

I'm manually requiring "services" where appropriate as the lib directory
isn't in the array of `autoload_paths`.

Note that we're already requiring "services" in section_reslugger.rb so
I haven't had to require it again.
Using a `Services` module to keep all the GdsApi clients together is a
pattern used in a number of other GOV.UK apps.

I'm manually requiring "services" where appropriate as the lib directory
isn't in the array of `autoload_paths`.
Using a `Services` module to keep all the GdsApi clients together is a
pattern used in a number of other GOV.UK apps.

Note that we're already requiring "services" in section_reslugger.rb so
I haven't had to require it again.
@chrisroos
Copy link
Contributor Author

I wonder whether it's worth also moving the ORGANISATIONS_API_BASE_PATH constant from its initializer into the new Services module. It might be worth seeing what other applications do.

I had a quick look at how other apps are instantiating GdsApi::Organisations and can see that they appear to be using Plek.new.find('whitehall-admin') directly. Manuals Publisher uses ORGANISATIONS_API_BASE_PATH so that it can specify an alternative API endpoint in development. This can already be achieved by using an environment variable to control Plek's behaviour (we made a similar change to Smart Answers). I'm going to leave ORGANSATIONS_API_BASE_PATH where it is in this branch but then remove it completely (and rely on Plek) in another branch.

I've somewhat arbitrarily chosen `Plek.find` but this could just as
easily be `Plek.new.find` or `Plek.current.find`.
@chrisroos chrisroos merged commit 0c345e5 into master Mar 16, 2017
@chrisroos chrisroos deleted the introduce-services-module branch March 16, 2017 12:46
@chrislo chrislo modified the milestone: Simplify Apr 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants