Module: Jat::Plugins::JsonApi

Defined in:
lib/jat/plugins/json_api/lib/map.rb,
lib/jat/plugins/json_api/json_api.rb,
lib/jat/plugins/json_api/lib/response.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/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/json_api/lib/params/fields/validate.rb,
lib/jat/plugins/json_api/lib/params/include/validate.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods, Params Classes: FieldsParamParser, IncludeParamParser, Map, Response, ResponsePiece

Class Method Summary collapse

Class Method Details

.after_load(jat_class, **opts) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/jat/plugins/json_api/json_api.rb', line 29

def self.after_load(jat_class, **opts)
  jat_class.config[:response_plugin_loaded] = plugin_name

  fields_parser_class = Class.new(FieldsParamParser)
  fields_parser_class.jat_class = jat_class
  jat_class.const_set(:FieldsParamParser, fields_parser_class)

  includes_parser_class = Class.new(IncludeParamParser)
  includes_parser_class.jat_class = jat_class
  jat_class.const_set(:IncludeParamParser, includes_parser_class)

  map_class = Class.new(Map)
  map_class.jat_class = jat_class
  jat_class.const_set(:Map, map_class)

  response_class = Class.new(Response)
  response_class.jat_class = jat_class
  jat_class.const_set(:Response, response_class)

  response_piece_class = Class.new(ResponsePiece)
  response_piece_class.jat_class = jat_class
  jat_class.const_set(:ResponsePiece, response_piece_class)

  jat_class.id
end

.before_load(jat_class, **_opts) ⇒ Object

Raises:



17
18
19
20
21
22
# File 'lib/jat/plugins/json_api/json_api.rb', line 17

def self.before_load(jat_class, **_opts)
  response_plugin = jat_class.config[:response_plugin_loaded]
  return unless response_plugin

  raise Error, "Response plugin `#{response_plugin}` was already loaded before"
end

.load(jat_class, **_opts) ⇒ Object



24
25
26
27
# File 'lib/jat/plugins/json_api/json_api.rb', line 24

def self.load(jat_class, **_opts)
  jat_class.include(InstanceMethods)
  jat_class.extend(ClassMethods)
end

.plugin_nameObject



13
14
15
# File 'lib/jat/plugins/json_api/json_api.rb', line 13

def self.plugin_name
  :json_api
end