lib/alephant/renderer/view_mapper.rb in alephant-renderer-3.1.0 vs lib/alephant/renderer/view_mapper.rb in alephant-renderer-3.2.0
- old
+ new
@@ -1,12 +1,10 @@
-require 'alephant/renderer/error/invalid_path'
-require 'alephant/logger'
+require 'alephant/renderer/error/invalid_base_path'
module Alephant
module Renderer
class ViewMapper
- include Logger
DEFAULT_LOCATION = 'components'.freeze
def initialize(renderer_id, view_base_path = nil)
self.base_path = "#{view_base_path}/#{renderer_id}" unless view_base_path.nil?
@@ -15,11 +13,11 @@
def base_path
@base_path || DEFAULT_LOCATION
end
def base_path=(path)
- @base_path = File.directory?(path) ? path : raise_error(path)
+ @base_path = File.directory?(path) ? path : raise(Error::InvalidBasePath.new(path))
end
def generate(data)
model_locations.reduce({}) do |obj, file|
model_id = model_id_for(file)
@@ -27,19 +25,9 @@
obj
end
end
private
-
- def raise_error(path)
- logger.metric('ViewMapperInvalidPath')
- logger.error(
- event: :ViewMapperBasePathInvalidFound,
- path: path,
- method: "#{self.class}#raise_error"
- )
- raise(Error::InvalidBasePath.new(path))
- end
def model(view_id, data)
require model_location_for view_id
Views.get_registered_class(view_id).new(data)
end