Sha256: 91048e6d9a6324478e755406f762a2f44377ac27dd76bb982ace0d9f07867aed

Contents?: true

Size: 911 Bytes

Versions: 2

Compression:

Stored size: 911 Bytes

Contents

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(request, options = {})
      @request_url = request.original_url[/\A[^?]+/]
      @query_parameters = request.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

2 entries across 2 versions & 1 rubygems

Version Path
active_model_serializers-0.10.0 lib/active_model_serializers/serialization_context.rb
active_model_serializers-0.10.0.rc5 lib/active_model_serializers/serialization_context.rb