Class: Wallaby::Map
- Inherits:
-
Object
- Object
- Wallaby::Map
- Extended by:
- Classifier
- Defined in:
- lib/wallaby/map.rb,
lib/services/wallaby/map/mode_mapper.rb,
lib/services/wallaby/map/model_class_mapper.rb
Overview
All the lookups that Wallaby needs.
Defined Under Namespace
Classes: ModeMapper, ModelClassMapper
Class Attribute Summary collapse
-
.class_name_error_map ⇒ Object
readonly
Cache the class name error.
-
.modes ⇒ Array<String>
All Modes.
Class Method Summary collapse
-
.authorizer_provider_map(model_class) ⇒ Class
{ model => authorizer_provider }.
-
.clear ⇒ Object
Reset all the instance variables to nil.
-
.id_regexp ⇒ Regexp
Regexp to match data for param ‘:id`.
-
.mode_map ⇒ ClassHash
{ Model Class => Mode }.
-
.model_class_map(resources_name, value = nil) ⇒ Class
{ resources name => model } It’s a setter when value is given.
- .model_classes ⇒ Object deprecated Deprecated.
-
.model_decorator_map(model_class, application_decorator) ⇒ ModelDecorator
{ model => model decorator }.
-
.pagination_provider_map(model_class) ⇒ Class
{ model => pagination_provider }.
-
.resources_name_map(model_class, value = nil) ⇒ String
{ model => resources name } It’s a setter when value is given.
-
.resources_regexp ⇒ Regexp
Regexp to match data for param ‘:resources`.
-
.service_provider_map(model_class) ⇒ Class
{ model => service_provider }.
Methods included from Classifier
Class Attribute Details
.class_name_error_map ⇒ Object (readonly)
Cache the class name error
108 109 110 |
# File 'lib/wallaby/map.rb', line 108 def class_name_error_map @class_name_error_map ||= {} end |
.modes ⇒ Array<String>
Returns all Wallaby::Modes.
14 15 16 |
# File 'lib/wallaby/map.rb', line 14 def modes @modes ||= ClassArray.new Mode.descendants end |
Class Method Details
.authorizer_provider_map(model_class) ⇒ Class
{ model => authorizer_provider }
87 88 89 90 |
# File 'lib/wallaby/map.rb', line 87 def (model_class) @authorizer_provider_map ||= ClassHash.new @authorizer_provider_map[model_class] ||= mode_map[model_class].try :model_authorization_providers end |
.clear ⇒ Object
Reset all the instance variables to nil
115 116 117 |
# File 'lib/wallaby/map.rb', line 115 def clear instance_variables.each { |name| instance_variable_set name, nil } end |
.id_regexp ⇒ Regexp
Returns regexp to match data for param ‘:id`.
100 101 102 |
# File 'lib/wallaby/map.rb', line 100 def id_regexp @id_regexp ||= IdRegexp.new.execute end |
.mode_map ⇒ ClassHash
Returns { Model Class => Wallaby::Mode }.
19 20 21 22 23 24 25 |
# File 'lib/wallaby/map.rb', line 19 def mode_map @mode_map ||= begin # NOTE: this is the point where all model files should be required Preloader.require_models ModeMapper.execute(modes).freeze end end |
.model_class_map(resources_name, value = nil) ⇒ Class
{ resources name => model } It’s a setter when value is given. Otherwise, a getter.
48 49 50 51 |
# File 'lib/wallaby/map.rb', line 48 def model_class_map(resources_name, value = nil) @model_class_map ||= ClassHash.new @model_class_map[resources_name] ||= value || Classifier.to_class(Inflector.to_model_name(resources_name)) end |
.model_classes ⇒ Object
28 29 30 |
# File 'lib/wallaby/map.rb', line 28 def model_classes Deprecator.alert method(__callee__), from: '0.3.0' end |
.model_decorator_map(model_class, application_decorator) ⇒ ModelDecorator
{ model => model decorator }
59 60 61 62 63 64 |
# File 'lib/wallaby/map.rb', line 59 def model_decorator_map(model_class, application_decorator) @model_decorator_map ||= ClassHash.new @model_decorator_map[application_decorator] ||= ClassHash.new @model_decorator_map[application_decorator][model_class] ||= mode_map[model_class].try(:model_decorator).try :new, model_class end |
.pagination_provider_map(model_class) ⇒ Class
{ model => pagination_provider }
79 80 81 82 |
# File 'lib/wallaby/map.rb', line 79 def pagination_provider_map(model_class) @pagination_provider_map ||= ClassHash.new @pagination_provider_map[model_class] ||= mode_map[model_class].try :model_pagination_provider end |
.resources_name_map(model_class, value = nil) ⇒ String
{ model => resources name } It’s a setter when value is given. Otherwise, a getter.
38 39 40 41 |
# File 'lib/wallaby/map.rb', line 38 def resources_name_map(model_class, value = nil) @resources_name_map ||= ClassHash.new @resources_name_map[model_class] ||= value || Inflector.to_resources_name(model_class) end |
.resources_regexp ⇒ Regexp
Returns regexp to match data for param ‘:resources`.
95 96 97 |
# File 'lib/wallaby/map.rb', line 95 def resources_regexp @resources_regexp ||= ResourcesRegexp.new.execute end |