Module: Skylight::Core::Normalizers Private

Defined in:
lib/skylight/core/normalizers.rb,
lib/skylight/core/normalizers/sql.rb,
lib/skylight/core/normalizers/render.rb,
lib/skylight/core/normalizers/default.rb,
lib/skylight/core/normalizers/sequel/sql.rb,
lib/skylight/core/normalizers/moped/query.rb,
lib/skylight/core/normalizers/active_storage.rb,
lib/skylight/core/normalizers/grape/endpoint.rb,
lib/skylight/core/normalizers/data_mapper/sql.rb,
lib/skylight/core/normalizers/faraday/request.rb,
lib/skylight/core/normalizers/graphiti/render.rb,
lib/skylight/core/normalizers/graphiti/resolve.rb,
lib/skylight/core/normalizers/active_record/sql.rb,
lib/skylight/core/normalizers/active_job/perform.rb,
lib/skylight/core/normalizers/couch_potato/query.rb,
lib/skylight/core/normalizers/grape/endpoint_run.rb,
lib/skylight/core/normalizers/active_support/cache.rb,
lib/skylight/core/normalizers/coach/handler_finish.rb,
lib/skylight/core/normalizers/elasticsearch/request.rb,
lib/skylight/core/normalizers/grape/endpoint_render.rb,
lib/skylight/core/normalizers/grape/format_response.rb,
lib/skylight/core/normalizers/coach/middleware_finish.rb,
lib/skylight/core/normalizers/active_support/cache_read.rb,
lib/skylight/core/normalizers/action_view/render_partial.rb,
lib/skylight/core/normalizers/active_support/cache_clear.rb,
lib/skylight/core/normalizers/active_support/cache_exist.rb,
lib/skylight/core/normalizers/active_support/cache_write.rb,
lib/skylight/core/normalizers/grape/endpoint_run_filters.rb,
lib/skylight/core/normalizers/action_controller/send_file.rb,
lib/skylight/core/normalizers/action_view/render_template.rb,
lib/skylight/core/normalizers/active_record/instantiation.rb,
lib/skylight/core/normalizers/active_support/cache_delete.rb,
lib/skylight/core/normalizers/action_view/render_collection.rb,
lib/skylight/core/normalizers/active_support/cache_generate.rb,
lib/skylight/core/normalizers/active_support/cache_decrement.rb,
lib/skylight/core/normalizers/active_support/cache_fetch_hit.rb,
lib/skylight/core/normalizers/active_support/cache_increment.rb,
lib/skylight/core/normalizers/active_model_serializers/render.rb,
lib/skylight/core/normalizers/active_support/cache_read_multi.rb,
lib/skylight/core/normalizers/action_controller/process_action.rb,
lib/skylight/core/normalizers/action_dispatch/process_middleware.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Convert AS::N events to Skylight events

Defined Under Namespace

Modules: ActionController, ActionDispatch, ActionView, ActiveJob, ActiveModelSerializers, ActiveRecord, ActiveSupport, Coach, CouchPotato, DataMapper, Elasticsearch, Faraday, Grape, GraphQL, Graphiti, Moped, Sequel Classes: ActiveStorage, Container, Default, Normalizer, RenderNormalizer, SQL

Constant Summary collapse

DEFAULT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Default.new

Class Method Summary collapse

Class Method Details

.build(config) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/skylight/core/normalizers.rb', line 34

def self.build(config)
  normalizers = {}

  registry.each do |key, (klass, enabled)|
    next unless enabled

    unless klass.method_defined?(:normalize)
      # TODO: Warn
      next
    end

    normalizers[key] = klass.new(config)
  end

  Container.new(normalizers)
end

.disable(*names) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


30
31
32
# File 'lib/skylight/core/normalizers.rb', line 30

def self.disable(*names)
  enable(*names, enabled: false)
end

.enable(*names, enabled: true) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


22
23
24
25
26
27
28
# File 'lib/skylight/core/normalizers.rb', line 22

def self.enable(*names, enabled: true)
  names.each do |name|
    matches = registry.select { |n, _| n =~ /(^|\.)#{name}$/ }
    raise ArgumentError, "no normalizers match #{name}" if matches.empty?
    matches.values.each { |v| v[1] = enabled }
  end
end

.register(name, klass, opts = {}) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


13
14
15
16
# File 'lib/skylight/core/normalizers.rb', line 13

def self.register(name, klass, opts = {})
  enabled = opts[:enabled] != false
  registry[name] = [klass, enabled]
end

.registryObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
# File 'lib/skylight/core/normalizers.rb', line 9

def self.registry
  @registry ||= {}
end

.unregister(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


18
19
20
# File 'lib/skylight/core/normalizers.rb', line 18

def self.unregister(name)
  @registry.delete(name)
end