jat 0.0.5 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jat/attribute.rb +5 -16
- data/lib/jat/config.rb +4 -7
- data/lib/jat/plugins/activerecord/activerecord.rb +23 -0
- data/lib/jat/plugins/{_activerecord_preloads/_activerecord_preloads.rb → base/base_activerecord_preloads/base_activerecord_preloads.rb} +7 -2
- data/lib/jat/plugins/{_activerecord_preloads → base/base_activerecord_preloads}/lib/preloader.rb +16 -4
- data/lib/jat/plugins/{_lower_camel_case/_lower_camel_case.rb → base/base_lower_camel_case/base_lower_camel_case.rb} +6 -2
- data/lib/jat/plugins/{_preloads/_preloads.rb → base/base_preloads/base_preloads.rb} +6 -2
- data/lib/jat/plugins/{_preloads → base/base_preloads}/lib/format_user_preloads.rb +1 -1
- data/lib/jat/plugins/{_preloads → base/base_preloads}/lib/preloads_with_path.rb +1 -1
- data/lib/jat/plugins/cache/cache.rb +5 -1
- data/lib/jat/plugins/json_api/json_api.rb +7 -3
- data/lib/jat/plugins/json_api/lib/map.rb +4 -5
- data/lib/jat/plugins/json_api/lib/response.rb +1 -5
- data/lib/jat/plugins/json_api/lib/response_piece.rb +19 -10
- data/lib/jat/plugins/json_api/plugins/json_api_activerecord/json_api_activerecord.rb +23 -0
- data/lib/jat/plugins/{json_api_lower_camel_case → json_api/plugins/json_api_lower_camel_case}/json_api_lower_camel_case.rb +6 -2
- data/lib/jat/plugins/{json_api_maps_cache → json_api/plugins/json_api_maps_cache}/json_api_maps_cache.rb +5 -1
- data/lib/jat/plugins/json_api/plugins/json_api_preloads/json_api_preloads.rb +38 -0
- data/lib/jat/plugins/{json_api_activerecord → json_api/plugins/json_api_preloads}/lib/preloads.rb +1 -1
- data/lib/jat/plugins/{json_api_validate_params → json_api/plugins/json_api_validate_params}/json_api_validate_params.rb +5 -1
- data/lib/jat/plugins/{json_api_validate_params → json_api/plugins/json_api_validate_params}/lib/params_error.rb +0 -0
- data/lib/jat/plugins/{json_api_validate_params → json_api/plugins/json_api_validate_params}/lib/validate_fields_param.rb +0 -0
- data/lib/jat/plugins/{json_api_validate_params → json_api/plugins/json_api_validate_params}/lib/validate_include_param.rb +1 -3
- data/lib/jat/plugins/lower_camel_case/lower_camel_case.rb +23 -0
- data/lib/jat/plugins/maps_cache/maps_cache.rb +23 -0
- data/lib/jat/plugins/preloads/preloads.rb +23 -0
- data/lib/jat/plugins/simple_api/lib/fields_param_parser.rb +20 -36
- data/lib/jat/plugins/simple_api/lib/map.rb +4 -5
- data/lib/jat/plugins/simple_api/lib/response.rb +1 -5
- data/lib/jat/plugins/simple_api/lib/response_piece.rb +1 -5
- data/lib/jat/plugins/simple_api/plugins/simple_api_activerecord/simple_api_activerecord.rb +23 -0
- data/lib/jat/plugins/{simple_api_lower_camel_case → simple_api/plugins/simple_api_lower_camel_case}/simple_api_lower_camel_case.rb +6 -2
- data/lib/jat/plugins/{simple_api_maps_cache → simple_api/plugins/simple_api_maps_cache}/simple_api_maps_cache.rb +6 -4
- data/lib/jat/plugins/{simple_api_activerecord → simple_api/plugins/simple_api_preloads}/lib/preloads.rb +1 -1
- data/lib/jat/plugins/simple_api/plugins/simple_api_preloads/simple_api_preloads.rb +38 -0
- data/lib/jat/plugins/{simple_api_validate_params → simple_api/plugins/simple_api_validate_params}/lib/fields_error.rb +0 -0
- data/lib/jat/plugins/{simple_api_validate_params → simple_api/plugins/simple_api_validate_params}/lib/validate_fields_param.rb +0 -0
- data/lib/jat/plugins/{simple_api_validate_params → simple_api/plugins/simple_api_validate_params}/simple_api_validate_params.rb +6 -2
- data/lib/jat/plugins/simple_api/simple_api.rb +8 -7
- data/lib/jat/plugins/to_str/to_str.rb +5 -1
- data/lib/jat/plugins/types/types.rb +55 -0
- data/lib/jat/plugins/validate_params/validate_params.rb +23 -0
- data/lib/jat/plugins.rb +41 -15
- data/lib/jat.rb +24 -17
- data/test/lib/jat/attribute_test.rb +8 -0
- data/test/lib/jat/plugins/activerecord/activerecord_test.rb +27 -0
- data/test/lib/jat/plugins/{_activerecord_preloads/_activerecord_preloads_test.rb → base_activerecord_preloads/base_activerecord_preloads_test.rb} +3 -3
- data/test/lib/jat/plugins/{_activerecord_preloads → base_activerecord_preloads}/lib/preloader_test.rb +2 -2
- data/test/lib/jat/plugins/{_camel_lower/_camel_lower_test.rb → base_lower_camel_case/base_lower_camel_case_test.rb} +2 -2
- data/test/lib/jat/plugins/{_preloads/_preloads_test.rb → base_preloads/base_preloads_test.rb} +2 -2
- data/test/lib/jat/plugins/{_preloads → base_preloads}/lib/format_user_preloads_test.rb +3 -3
- data/test/lib/jat/plugins/{_preloads → base_preloads}/lib/preloads_with_path_test.rb +2 -2
- data/test/lib/jat/plugins/json_api/json_api_test.rb +1 -9
- data/test/lib/jat/plugins/json_api/lib/fields_param_parser_test.rb +20 -12
- data/test/lib/jat/plugins/json_api/lib/include_param_parser_test.rb +25 -11
- data/test/lib/jat/plugins/json_api/lib/map_test.rb +132 -124
- data/test/lib/jat/plugins/json_api/lib/response_piece_test.rb +13 -0
- data/test/lib/jat/plugins/json_api/lib/response_test.rb +6 -1
- data/test/lib/jat/plugins/json_api_activerecord/json_api_activerecord_test.rb +4 -18
- data/test/lib/jat/plugins/{json_api_camel_lower/json_api_camel_lower_test.rb → json_api_lower_camel_case/json_api_lower_camel_case_test.rb} +6 -0
- data/test/lib/jat/plugins/json_api_preloads/json_api_preloads_test.rb +51 -0
- data/test/lib/jat/plugins/{json_api_activerecord → json_api_preloads}/lib/preloads_test.rb +8 -6
- data/test/lib/jat/plugins/json_api_validate_params/json_api_validate_params_test.rb +30 -6
- data/test/lib/jat/plugins/lower_camel_case/lower_camel_case_test.rb +27 -0
- data/test/lib/jat/plugins/maps_cache/maps_cache_test.rb +27 -0
- data/test/lib/jat/plugins/preloads/preloads_test.rb +27 -0
- data/test/lib/jat/plugins/simple_api/lib/fields_param_parser_test.rb +57 -43
- data/test/lib/jat/plugins/simple_api/lib/map_test.rb +90 -82
- data/test/lib/jat/plugins/simple_api/lib/response_piece_test.rb +13 -0
- data/test/lib/jat/plugins/simple_api/lib/response_test.rb +18 -12
- data/test/lib/jat/plugins/simple_api/simple_api_test.rb +33 -6
- data/test/lib/jat/plugins/simple_api_activerecord/simple_api_activerecord_test.rb +4 -18
- data/test/lib/jat/plugins/{simple_api_camel_lower/simple_api_camel_lower_test.rb → simple_api_lower_camel_case/simple_api_lower_camel_case_test.rb} +7 -1
- data/test/lib/jat/plugins/{simple_api_activerecord → simple_api_preloads}/lib/preloads_test.rb +8 -8
- data/test/lib/jat/plugins/simple_api_preloads/simple_api_preloads_test.rb +51 -0
- data/test/lib/jat/plugins/simple_api_validate_params/simple_api_validate_params_test.rb +12 -0
- data/test/lib/jat/plugins/types/types_test.rb +83 -0
- data/test/lib/jat/plugins/validate_params/validate_params_test.rb +27 -0
- data/test/lib/jat/plugins_test.rb +88 -0
- data/test/test_helper.rb +8 -4
- metadata +98 -82
- data/lib/jat/plugins/json_api_activerecord/json_api_activerecord.rb +0 -31
- data/lib/jat/plugins/simple_api_activerecord/simple_api_activerecord.rb +0 -31
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "./lib/preloads"
|
4
|
-
|
5
|
-
class Jat
|
6
|
-
module Plugins
|
7
|
-
module JsonApiActiverecord
|
8
|
-
def self.before_load(jat_class, **opts)
|
9
|
-
return if jat_class.plugin_used?(:json_api)
|
10
|
-
raise Error, "Please load :json_api plugin first"
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.load(jat_class, **_opts)
|
14
|
-
jat_class.include(InstanceMethods)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.after_load(jat_class, **opts)
|
18
|
-
jat_class.plugin :_preloads, **opts
|
19
|
-
jat_class.plugin :_activerecord_preloads, **opts
|
20
|
-
end
|
21
|
-
|
22
|
-
module InstanceMethods
|
23
|
-
def preloads
|
24
|
-
@preloads ||= Preloads.call(self)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
register_plugin(:json_api_activerecord, JsonApiActiverecord)
|
30
|
-
end
|
31
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "./lib/preloads"
|
4
|
-
|
5
|
-
class Jat
|
6
|
-
module Plugins
|
7
|
-
module SimpleApiActiverecord
|
8
|
-
def self.before_load(jat_class, **_opts)
|
9
|
-
return if jat_class.plugin_used?(:simple_api)
|
10
|
-
raise Error, "Please load :simple_api plugin first"
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.load(jat_class, **_opts)
|
14
|
-
jat_class.include(InstanceMethods)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.after_load(jat_class, **opts)
|
18
|
-
jat_class.plugin :_preloads, **opts
|
19
|
-
jat_class.plugin :_activerecord_preloads, **opts
|
20
|
-
end
|
21
|
-
|
22
|
-
module InstanceMethods
|
23
|
-
def preloads
|
24
|
-
@preloads ||= Preloads.call(self)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
register_plugin(:simple_api_activerecord, SimpleApiActiverecord)
|
30
|
-
end
|
31
|
-
end
|