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
22 23 24 25 26 27 28 |
# File 'lib/bitbucket_rest_api/api_factory.rb', line 22 def self.convert_to_constant(classes) constant = BitBucket classes.split('::').each do |klass| constant = constant.const_get klass end return constant end |
.create_instance(klass, options) ⇒ Object
Passes configuration options to instantiated class
15 16 17 18 19 20 |
# File 'lib/bitbucket_rest_api/api_factory.rb', line 15 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
9 10 11 12 |
# File 'lib/bitbucket_rest_api/api_factory.rb', line 9 def self.new(klass, ={}) return create_instance(klass, ) if klass raise ArgumentError, 'must provide klass to be instantiated' end |