Class: Checklister::Client
- Inherits:
-
Object
- Object
- Checklister::Client
- Defined in:
- lib/checklister/client.rb
Overview
Implement a kind of Factory pattern
We create an object without exposing the creation logic and then refer to newly created object using a common interface.
Constant Summary collapse
- IMPLEMENTED_BACKENDS =
The issue service backends we are currently supporting
- [x] gitlab
- [x] github
- [ ] bitbucket
%w(gitlab github)
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Object
constructor
Initialize all the issue service options required to be able to interact with it.
- #issue ⇒ Object
- #project ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Object
Initialize all the issue service options required to be able to interact with it
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/checklister/client.rb', line 33 def initialize( = {}) @kind = .fetch(:kind) { raise ArgumentError, "No API client can be initialized" } raise(NotImplementedError, "No #{@kind} API client has been implemented") unless IMPLEMENTED_BACKENDS.include?(@kind) @options = .reject { |k| [:kind].include? k } = { user_agent: "Checklister for #{@kind} #{Checklister::VERSION}" } @options.merge! @options_for_kind = (@options, @kind) @project_klass = nil @issue_klass = nil define_classes_for_kind(@kind) @api_client = get_api_client end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/checklister/client.rb', line 17 def api_client @api_client end |
Instance Method Details
#issue ⇒ Object
50 51 52 |
# File 'lib/checklister/client.rb', line 50 def issue @issue ||= @issue_klass.new(@api_client) end |
#project ⇒ Object
46 47 48 |
# File 'lib/checklister/client.rb', line 46 def project @project ||= @project_klass.new(@api_client) end |