Module: RESTFramework

Defined in:
lib/rest_framework/version.rb,
lib/rest_framework.rb

Overview

Do not use Rails-specific helper methods here (e.g., ‘blank?`) so the module can run standalone.

Defined Under Namespace

Modules: BaseControllerMixin, BaseModelControllerMixin, BulkCreateModelMixin, BulkDestroyModelMixin, BulkModelControllerMixin, BulkUpdateModelMixin, ControllerMixins, CreateModelMixin, DestroyModelMixin, Filters, Generators, ListModelMixin, ModelControllerMixin, ReadOnlyModelControllerMixin, ShowModelMixin, UpdateModelMixin, Utils, Version Classes: ActiveModelSerializerAdapterFactory, BaseFilter, BasePaginator, BaseSerializer, Config, Engine, Error, ModelOrderingFilter, ModelQueryFilter, ModelSearchFilter, NativeSerializer, NilPassedToAPIResponseError, PageNumberPaginator, RansackFilter, UnknownModelError

Constant Summary collapse

BUILTIN_ACTIONS =
{
  index: :get,
  new: :get,
  create: :post,
}.freeze
BUILTIN_MEMBER_ACTIONS =
{
  show: :get,
  edit: :get,
  update: [:put, :patch].freeze,
  destroy: :delete,
}.freeze
RRF_BUILTIN_ACTIONS =
{
  options: :options,
}.freeze
RRF_BUILTIN_BULK_ACTIONS =
{
  update_all: [:put, :patch].freeze,
  destroy_all: :delete,
}.freeze
EXTERNAL_ASSETS =

We should always add the ‘.min` extension prefix even if the assets are not minified, to avoid sprockets minifying the assets. We target propshaft, so we want these assets to just be passed through. rubocop:disable Layout/LineLength

{
  # Bootstrap
  "bootstrap.min.css" => {
    url: "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",
    sri: "sha384-aFq/bzH65dt+w6FI2ooMVUpc+21e0SRygnTpmBvdBgSdnuTN7QbdgL+OapgHtvPp",
  },
  "bootstrap.min.js" => {
    url: "https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js",
    sri: "sha384-qKXV1j0HvMUeCBQ+QVp7JcfGl760yU08IQ+GpUo5hlbpg51QRiuqHAJz8+BrxE/N",
  },

  # Bootstrap Icons
  "bootstrap-icons.min.css" => {
    url: "https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css",
    inline_fonts: true,
  },

  # Highlight.js
  "highlight.min.js" => {
    url: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js",
    sri: "sha512-bgHRAiTjGrzHzLyKOnpFvaEpGzJet3z4tZnXGjpsCcqOnAH6VGUx9frc5bcIhKTVLEiCO6vEhNAgx5jtLUYrfA==",
  },
  "highlight-json.min.js" => {
    url: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/json.min.js",
    sri: "sha512-0xYvyncS9OLE7GOpNBZFnwyh9+bq4HVgk4yVVYI678xRvE22ASicF1v6fZ1UiST+M6pn17MzFZdvVCI3jTHSyw==",
  },
  "highlight-xml.min.js" => {
    url: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/languages/xml.min.js",
    sri: "sha512-5zBcw+OKRkaNyvUEPlTSfYylVzgpi7KpncY36b0gRudfxIYIH0q0kl2j26uCUB3YBRM6ytQQEZSgRg+ZlBTmdA==",
  },
  "highlight-a11y-dark.min.css" => {
    url: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/a11y-dark.min.css",
    sri: "sha512-Vj6gPCk8EZlqnoveEyuGyYaWZ1+jyjMPg8g4shwyyNlRQl6d3L9At02ZHQr5K6s5duZl/+YKMnM3/8pDhoUphg==",
    extra_tag_attrs: {class: "rrf-dark-mode"},
  },
  "highlight-a11y-light.min.css" => {
    url: "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/a11y-light.min.css",
    sri: "sha512-WDk6RzwygsN9KecRHAfm9HTN87LQjqdygDmkHSJxVkVI7ErCZ8ZWxP6T8RvBujY1n2/E4Ac+bn2ChXnp5rnnHA==",
    extra_tag_attrs: {class: "rrf-light-mode"},
  },

  # NeatJSON
  "neatjson.min.js" => {
    url: "https://cdn.jsdelivr.net/npm/[email protected]/javascript/neatjson.min.js",
    exclude_from_docs: true,
  },

  # Trix
  "trix.min.css" => {
    url: "https://unpkg.com/[email protected]/dist/trix.css",
    exclude_from_docs: true,
  },
  "trix.min.js" => {
    url: "https://unpkg.com/[email protected]/dist/trix.umd.min.js",
    exclude_from_docs: true,
  },
}.map { |name, cfg|
  if File.extname(name) == ".js"
    cfg[:place] = "javascripts"
    cfg[:extra_tag_attrs] ||= {}
    cfg[:tag_attrs] = {
      src: cfg[:url],
      integrity: cfg[:sri],
      crossorigin: "anonymous",
      referrerpolicy: "no-referrer",
      defer: true,
      **cfg[:extra_tag_attrs],
    }
    cfg[:tag] = ActionController::Base.helpers.tag.script(**cfg[:tag_attrs])
  else
    cfg[:place] = "stylesheets"
    cfg[:extra_tag_attrs] ||= {}
    cfg[:tag_attrs] = {
      rel: "stylesheet",
      href: cfg[:url],
      integrity: cfg[:sri],
      crossorigin: "anonymous",
      **cfg[:extra_tag_attrs],
    }
    cfg[:tag] = ActionController::Base.helpers.tag.link(**cfg[:tag_attrs])
  end

  [name, cfg]
}.to_h.freeze
VERSION =
Version.get_version

Class Method Summary collapse

Class Method Details

.configObject



160
161
162
# File 'lib/rest_framework.rb', line 160

def self.config
  return @config ||= Config.new
end

.configure {|self.config| ... } ⇒ Object

Yields:



164
165
166
# File 'lib/rest_framework.rb', line 164

def self.configure
  yield(self.config)
end

.featuresObject



168
169
170
# File 'lib/rest_framework.rb', line 168

def self.features
  return @features ||= {}
end