Class: Alephant::Publisher::Request::DataMapperFactory
- Inherits:
-
Object
- Object
- Alephant::Publisher::Request::DataMapperFactory
- Includes:
- LogHelper
- Defined in:
- lib/alephant/publisher/request/data_mapper_factory.rb
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
- #create(component_id, context = {}) ⇒ Object
-
#initialize(connection, base_path) ⇒ DataMapperFactory
constructor
A new instance of DataMapperFactory.
Methods included from LogHelper
Constructor Details
#initialize(connection, base_path) ⇒ DataMapperFactory
Returns a new instance of DataMapperFactory.
11 12 13 14 15 |
# File 'lib/alephant/publisher/request/data_mapper_factory.rb', line 11 def initialize(connection, base_path) @connection = connection @base_path = base_path raise InvalidComponentBasePath, base_path unless File.directory? base_path end |
Instance Attribute Details
#base_path ⇒ Object (readonly)
Returns the value of attribute base_path.
9 10 11 |
# File 'lib/alephant/publisher/request/data_mapper_factory.rb', line 9 def base_path @base_path end |
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
9 10 11 |
# File 'lib/alephant/publisher/request/data_mapper_factory.rb', line 9 def connection @connection end |
Instance Method Details
#create(component_id, context = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/alephant/publisher/request/data_mapper_factory.rb', line 17 def create(component_id, context = {}) require base_path_for component_id klass = mapper_class_for(component_id) klass.new(connection, context) rescue LoadError => e log_error_with_metric(e, component_id, "PublisherRequestDataMapperFactoryInvalidComponentName") raise InvalidComponentName, "Invalid component name: #{component_id}" rescue NameError => e log_error_with_metric(e, component_id, "PublisherRequestDataMapperFactoryInvalidComponentClassName") raise InvalidComponentClassName, "Invalid class name #{klass}" rescue => e log_error_with_metric(e, component_id, "PublisherRequestDataMapperFactoryInvalidComponent") raise InvalidComponent, "Name: #{component_id}, Class: #{klass}" end |