Sha256: 4adbef2d7567b0178e468505538c94b2cf5f52d4a53beb233dc5e58226b512dd

Contents?: true

Size: 638 Bytes

Versions: 3

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

module ActiveModel
  class Serializer
    class Config
      def initialize(data = {})
        @data = data
      end

      def each(&block)
        @data.each(&block)
      end

      def clear
        @data.clear
      end

      def method_missing(name, *args)
        name = name.to_s
        return @data[name] if @data.include?(name)
        match = name.match(/\A(.*?)([?=]?)\Z/)
        case match[2]
        when "="
          @data[match[1]] = args.first
        when "?"
          !!@data[match[1]]
        end
      end
    end

    CONFIG = Config.new('embed' => :objects) # :nodoc:
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
active_model_serializers-0.9.13 lib/active_model/serializer/config.rb
active_model_serializers-0.9.12 lib/active_model/serializer/config.rb
active_model_serializers-0.9.11 lib/active_model/serializer/config.rb