Class: Wallaby::DecoratorFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/services/wallaby/decorator_finder.rb

Constant Summary collapse

DEFAULT_DECORATOR =
Wallaby::ResourceDecorator

Class Method Summary collapse

Class Method Details

.find_model(model_class) ⇒ Object



4
5
6
# File 'lib/services/wallaby/decorator_finder.rb', line 4

def self.find_model(model_class)
  Wallaby::Map.decorator_map[model_class] || new_model(model_class)
end

.find_resource(model_class) ⇒ Object



8
9
10
# File 'lib/services/wallaby/decorator_finder.rb', line 8

def self.find_resource(model_class)
  Wallaby::Map.decorator_map[model_class] || DEFAULT_DECORATOR
end

.new_model(model_class) ⇒ Object



12
13
14
15
# File 'lib/services/wallaby/decorator_finder.rb', line 12

def self.new_model(model_class)
  mode = Wallaby::ActiveRecord
  mode.model_decorator.new model_class
end