Module: Jat::Plugins
- Defined in:
- lib/jat/plugins.rb,
lib/jat/plugins/cache/cache.rb,
lib/jat/plugins/types/types.rb,
lib/jat/plugins/to_str/to_str.rb,
lib/jat/plugins/json_api/lib/map.rb,
lib/jat/plugins/json_api/json_api.rb,
lib/jat/plugins/preloads/preloads.rb,
lib/jat/plugins/simple_api/lib/map.rb,
lib/jat/plugins/presenter/presenter.rb,
lib/jat/plugins/json_api/lib/response.rb,
lib/jat/plugins/maps_cache/maps_cache.rb,
lib/jat/plugins/simple_api/simple_api.rb,
lib/jat/plugins/simple_api/lib/response.rb,
lib/jat/plugins/activerecord/activerecord.rb,
lib/jat/plugins/json_api/lib/params/fields.rb,
lib/jat/plugins/json_api/lib/params/include.rb,
lib/jat/plugins/json_api/lib/response_piece.rb,
lib/jat/plugins/simple_api/lib/response_piece.rb,
lib/jat/plugins/validate_params/validate_params.rb,
lib/jat/plugins/base/base_preloads/base_preloads.rb,
lib/jat/plugins/json_api/lib/fields_param_parser.rb,
lib/jat/plugins/json_api/lib/params/fields/parse.rb,
lib/jat/plugins/json_api/lib/include_param_parser.rb,
lib/jat/plugins/json_api/lib/params/include/parse.rb,
lib/jat/plugins/lower_camel_case/lower_camel_case.rb,
lib/jat/plugins/simple_api/lib/fields_param_parser.rb,
lib/jat/plugins/json_api/lib/params/fields/validate.rb,
lib/jat/plugins/json_api/lib/params/include/validate.rb,
lib/jat/plugins/base/base_preloads/lib/preloads_with_path.rb,
lib/jat/plugins/base/base_preloads/lib/format_user_preloads.rb,
lib/jat/plugins/base/base_activerecord_preloads/lib/preloader.rb,
lib/jat/plugins/json_api/plugins/json_api_preloads/lib/preloads.rb,
lib/jat/plugins/base/base_lower_camel_case/base_lower_camel_case.rb,
lib/jat/plugins/simple_api/plugins/simple_api_preloads/lib/preloads.rb,
lib/jat/plugins/json_api/plugins/json_api_preloads/json_api_preloads.rb,
lib/jat/plugins/json_api/plugins/json_api_maps_cache/json_api_maps_cache.rb,
lib/jat/plugins/base/base_activerecord_preloads/base_activerecord_preloads.rb,
lib/jat/plugins/simple_api/plugins/simple_api_preloads/simple_api_preloads.rb,
lib/jat/plugins/json_api/plugins/json_api_activerecord/json_api_activerecord.rb,
lib/jat/plugins/simple_api/plugins/simple_api_maps_cache/simple_api_maps_cache.rb,
lib/jat/plugins/json_api/plugins/json_api_validate_params/json_api_validate_params.rb,
lib/jat/plugins/simple_api/plugins/simple_api_activerecord/simple_api_activerecord.rb,
lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_fields_param.rb,
lib/jat/plugins/json_api/plugins/json_api_lower_camel_case/json_api_lower_camel_case.rb,
lib/jat/plugins/json_api/plugins/json_api_validate_params/lib/validate_include_param.rb,
lib/jat/plugins/simple_api/plugins/simple_api_validate_params/lib/validate_fields_param.rb,
lib/jat/plugins/simple_api/plugins/simple_api_validate_params/simple_api_validate_params.rb,
lib/jat/plugins/simple_api/plugins/simple_api_lower_camel_case/simple_api_lower_camel_case.rb
Defined Under Namespace
Modules: Activerecord, BaseActiverecordPreloads, BaseLowerCamelCase, BasePreloads, Cache, JsonApi, JsonApiActiverecord, JsonApiLowerCamelCase, JsonApiMapsCache, JsonApiPreloads, JsonApiValidateParams, LowerCamelCase, MapsCache, Preloads, Presenter, SimpleApi, SimpleApiActiverecord, SimpleApiLowerCamelCase, SimpleApiMapsCache, SimpleApiPreloads, SimpleApiValidateParams, ToStr, Types, ValidateParams
Class Method Summary collapse
-
.find_plugin(name) ⇒ Object
If the registered plugin already exists, use it.
-
.register_plugin(name, mod) ⇒ Object
Registers given plugin to be able to load it using symbol name.
Class Method Details
.find_plugin(name) ⇒ Object
If the registered plugin already exists, use it. Otherwise, require and return it. This raises a LoadError if such a plugin doesn’t exist, or a Jat::Error if it exists but it does not register itself correctly.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/jat/plugins.rb', line 21 def find_plugin(name) return name if name.is_a?(Module) return @plugins[name] if @plugins.key?(name) begin require_plugin(name) rescue PluginLoadError name_str = name.to_s if name_str.start_with?("json_api") require_plugin(name, "/json_api/plugins") elsif name_str.start_with?("simple_api") require_plugin(name, "/simple_api/plugins") elsif name_str.start_with?("base") require_plugin(name, "/base") else raise end end @plugins[name] || raise(PluginLoadError, "Plugin '#{name}' did not register itself correctly") end |
.register_plugin(name, mod) ⇒ Object
Registers given plugin to be able to load it using symbol name.
Example: Jat::Plugins.register_plugin(:plugin_name, PluginModule)
13 14 15 |
# File 'lib/jat/plugins.rb', line 13 def register_plugin(name, mod) @plugins[name] = mod end |