Class: Wallaby::Map
- Inherits:
-
Object
- Object
- Wallaby::Map
- Defined in:
- lib/services/wallaby/map.rb
Class Method Summary collapse
- .controller_map ⇒ Object
- .decorator_map ⇒ Object
- .mode_map(modes = nil) ⇒ Object
- .model_class_map(base_class, method_id) ⇒ Object
- .model_classes(configuration = nil) ⇒ Object
- .servicer_map ⇒ Object
Class Method Details
.controller_map ⇒ Object
30 31 32 |
# File 'lib/services/wallaby/map.rb', line 30 def self.controller_map model_class_map Wallaby::ResourcesController, __callee__ end |
.decorator_map ⇒ Object
34 35 36 |
# File 'lib/services/wallaby/map.rb', line 34 def self.decorator_map model_class_map Wallaby::ResourceDecorator, __callee__ end |
.mode_map(modes = nil) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/services/wallaby/map.rb', line 2 def self.mode_map(modes = nil) Rails.cache.fetch 'wallaby/map/mode_map' do {}.tap do |map| (modes || Wallaby::Mode.subclasses).each do |mode_class| mode_class.model_finder.new.all.each do |model_class| map[model_class] = mode_class end end end end end |
.model_class_map(base_class, method_id) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/services/wallaby/map.rb', line 42 def self.model_class_map(base_class, method_id) Rails.cache.fetch "wallaby/map/#{ method_id }" do {}.tap do |map| base_class.subclasses .reject{ |klass| klass.name.blank? } .each do |klass| map[klass.model_class] = klass end end end end |
.model_classes(configuration = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/services/wallaby/map.rb', line 14 def self.model_classes(configuration = nil) Rails.cache.fetch 'wallaby/map/model_classes' do models = (configuration || Wallaby.configuration).models full_list = mode_map.keys configed_models = models.presence return full_list - models.excludes unless configed_models invalid_models = configed_models - full_list if invalid_models.length > 0 fail Wallaby::InvalidError, "#{ invalid_models.to_sentence } are invalid models." end configed_models end end |
.servicer_map ⇒ Object
38 39 40 |
# File 'lib/services/wallaby/map.rb', line 38 def self.servicer_map model_class_map Wallaby::ModelServicer, __callee__ end |