Class: BitBucket::ApiFactory
- Inherits:
-
Object
- Object
- BitBucket::ApiFactory
- Defined in:
- lib/bitbucket_rest_api/api_factory.rb
Class Method Summary collapse
- .convert_to_constant(classes) ⇒ Object
-
.create_instance(klass, options) ⇒ Object
Passes configuration options to instantiated class.
-
.new(klass, options = {}) ⇒ Object
Instantiates a new bitbucket api object.
Class Method Details
.convert_to_constant(classes) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/bitbucket_rest_api/api_factory.rb', line 21 def self.convert_to_constant(classes) constant = BitBucket classes.split('::').each do |klass| constant = constant.const_get klass end constant end |
.create_instance(klass, options) ⇒ Object
Passes configuration options to instantiated class
14 15 16 17 18 19 |
# File 'lib/bitbucket_rest_api/api_factory.rb', line 14 def self.create_instance(klass, ) .symbolize_keys! instance = convert_to_constant(klass.to_s).new BitBucket.api_client = instance instance end |
.new(klass, options = {}) ⇒ Object
Instantiates a new bitbucket api object
7 8 9 10 11 |
# File 'lib/bitbucket_rest_api/api_factory.rb', line 7 def self.new(klass, = {}) return create_instance(klass, ) if klass raise ArgumentError, 'must provide klass to be instantiated' end |