Sha256: ce178341e5d5a047bd7d25c254fc40090388c63011f753e2957aa1ddaf857cc8

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

module Swagger
  module Serializer
    class Store
      class << self
        def current
          @current ||= new
        end
      end

      attr_reader :options

      def initialize(options = nil)
        @options = options || {}
        @options[:inject_key] ||= "title"
        @options[:injectors] ||= Injectors.new(cache: @options[:cache])
      end

      def serializer_options
        @options
      end

      class Injectors
        def initialize(injectors: {}, cache: false)
          @injectors = injectors
          @cache = cache
        end

        def [](name)
          if @cache
            @injectors[name] ||= "#{name}Serializer".safe_constantize
          else
            "#{name}Serializer".safe_constantize
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
swagger-serializer-0.5.2 lib/swagger/serializer/store.rb
swagger-serializer-0.5.1 lib/swagger/serializer/store.rb
swagger-serializer-0.5.0 lib/swagger/serializer/store.rb
swagger-serializer-0.4.1 lib/swagger/serializer/store.rb
swagger-serializer-0.4.0 lib/swagger/serializer/store.rb