Sha256: 42c202acac94475be92ad797c7b54bc7a1a31c3a386d190a69d697175a1ca791
Contents?: true
Size: 1.18 KB
Versions: 8
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'active_support/core_ext/array/extract_options' module ActiveModelSerializers class SerializationContext class << self attr_writer :url_helpers, :default_url_options def url_helpers @url_helpers ||= Module.new end def default_url_options @default_url_options ||= {} end end module UrlHelpers def self.included(base) base.send(:include, SerializationContext.url_helpers) end def default_url_options SerializationContext.default_url_options end end attr_reader :request_url, :query_parameters, :key_transform def initialize(*args) options = args.extract_options! if args.size == 1 request = args.pop options[:request_url] = request.original_url[/\A[^?]+/] options[:query_parameters] = request.query_parameters end @request_url = options.delete(:request_url) @query_parameters = options.delete(:query_parameters) @url_helpers = options.delete(:url_helpers) || self.class.url_helpers @default_url_options = options.delete(:default_url_options) || self.class.default_url_options end end end
Version data entries
8 entries across 8 versions & 2 rubygems