Sha256: 8e9b1da27d79ee59ba6e339bb7a365b2280c93d95f553020593b18ceec747542

Contents?: true

Size: 607 Bytes

Versions: 14

Compression:

Stored size: 607 Bytes

Contents

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

14 entries across 14 versions & 2 rubygems

Version Path
active_model_serializers-0.9.9 lib/active_model/serializer/config.rb
active_model_serializers-0.9.8 lib/active_model/serializer/config.rb
active_model_serializers-0.9.7 lib/active_model/serializer/config.rb
active_model_serializers-0.9.6 lib/active_model/serializer/config.rb
active_model_serializers-0.9.5 lib/active_model/serializer/config.rb
active_model_serializers-0.9.4 lib/active_model/serializer/config.rb
active_model_serializers-0.9.3 lib/active_model/serializer/config.rb
active_model_serializers-0.9.2 lib/active_model/serializer/config.rb
active_model_serializers-0.9.1 lib/active_model/serializer/config.rb
active_model_serializers-0.9.0 lib/active_model/serializer/config.rb
active_model_serializers_rails_2.3-0.9.0.alpha1 lib/active_model/serializer/config.rb
active_model_serializers-0.9.0.alpha1 lib/active_model/serializer/config.rb
active_model_serializers_rails_2.3-0.9.0.pre2 lib/active_model/serializer/config.rb
active_model_serializers_rails_2.3-0.9.0.pre1 lib/active_model/serializer/config.rb