Class: Wallaby::Map

Inherits:
Object
  • Object
show all
Defined in:
lib/services/wallaby/map.rb,
lib/services/wallaby/map/mode_mapper.rb,
lib/services/wallaby/map/model_class_mapper.rb,
lib/services/wallaby/map/model_class_collector.rb

Overview

Global mappings

Defined Under Namespace

Classes: ModeMapper, ModelClassCollector, ModelClassMapper

Class Method Summary collapse

Class Method Details

.clearObject

Clear all the class variables to nil



108
109
110
111
112
113
# File 'lib/services/wallaby/map.rb', line 108

def clear
  @mode_map, @model_classes, @controller_map, @model_decorator_map,
  @resource_decorator_map, @servicer_map, @service_provider_map,
  @paginator_map, @pagination_provider_map, @model_class_map,
  @resources_name_map = []
end

.controller_map(model_class) ⇒ Class

{ model => controller }



21
22
23
24
25
# File 'lib/services/wallaby/map.rb', line 21

def controller_map(model_class)
  @controller_map ||=
    ModelClassMapper.new(mapping.resources_controller).map
  @controller_map[model_class] ||= mapping.resources_controller
end

.mode_mapHash

{ model => mode }



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

def mode_map
  @mode_map ||= ModeMapper.new(Mode.descendants).map.freeze
end

.model_class_map(resources_name) ⇒ Class

{ resources name => model }



102
103
104
105
# File 'lib/services/wallaby/map.rb', line 102

def model_class_map(resources_name)
  @model_class_map ||= {}
  @model_class_map[resources_name] ||= Utils.to_model_class resources_name
end

.model_classesArray



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

def model_classes
  @model_classes ||= ModelClassCollector.new(configuration).collect.freeze
end

.model_decorator_map(model_class) ⇒ Wallaby::ModelDecorator

{ model => model decorator }



30
31
32
33
34
35
36
# File 'lib/services/wallaby/map.rb', line 30

def model_decorator_map(model_class)
  @model_decorator_map ||= {}
  @model_decorator_map[model_class] ||= begin
    mode = mode_map[model_class]
    mode.model_decorator.new model_class if mode # rubocop:disable Style/SafeNavigation, Metrics/LineLength
  end
end

.pagination_provider_map(model_class) ⇒ Class

{ model => pagination_provider }



85
86
87
88
89
# File 'lib/services/wallaby/map.rb', line 85

def pagination_provider_map(model_class)
  @pagination_provider_map ||= {}
  @pagination_provider_map[model_class] ||=
    mode_map[model_class].try(:model_pagination_provider)
end

.paginator_map(model_class) ⇒ Hash

{ model => paginator }



75
76
77
78
79
80
# File 'lib/services/wallaby/map.rb', line 75

def paginator_map(model_class)
  @paginator_map ||= ModelClassMapper.new(mapping.resource_paginator).map
  @paginator_map[model_class] ||= begin
    mapping.resource_paginator if mode_map[model_class]
  end
end

.resource_decorator_map(model_class) ⇒ Class

{ model => resource decorator }



42
43
44
45
46
47
48
# File 'lib/services/wallaby/map.rb', line 42

def resource_decorator_map(model_class)
  @resource_decorator_map ||=
    ModelClassMapper.new(mapping.resource_decorator).map
  @resource_decorator_map[model_class] ||= begin
    mapping.resource_decorator if mode_map[model_class]
  end
end

.resources_name_map(model_class) ⇒ String

{ model => resources name }



94
95
96
97
# File 'lib/services/wallaby/map.rb', line 94

def resources_name_map(model_class)
  @resources_name_map ||= {}
  @resources_name_map[model_class] ||= Utils.to_resources_name model_class
end

.service_provider_map(model_class) ⇒ Wallaby::ModelServiceProvider

{ model => service_provider }



64
65
66
67
68
69
70
# File 'lib/services/wallaby/map.rb', line 64

def service_provider_map(model_class)
  @service_provider_map ||= {}
  @service_provider_map[model_class] ||= begin
    mode = mode_map[model_class]
    mode.model_service_provider.new model_class if mode # rubocop:disable Style/SafeNavigation, Metrics/LineLength
  end
end

.servicer_map(model_class) ⇒ Class

{ model => servicer }



54
55
56
57
58
59
# File 'lib/services/wallaby/map.rb', line 54

def servicer_map(model_class)
  @servicer_map ||= ModelClassMapper.new(mapping.model_servicer).map
  @servicer_map[model_class] ||= begin
    mapping.model_servicer if mode_map[model_class]
  end
end