Sha256: 3c49348c36ed81ed2a29504b9548b77d8e37911a1f2964c859d0d43f9540841d

Contents?: true

Size: 711 Bytes

Versions: 6

Compression:

Stored size: 711 Bytes

Contents

module ActiveModel
  class Serializer
    # This class holds all information about serializer's association.
    #
    # @attr [Symbol] name
    # @attr [Hash{Symbol => Object}] options
    # @attr [block]
    #
    # @example
    #  Association.new(:comments, { serializer: CommentSummarySerializer })
    #
    class Association < Field
      # @return [Symbol]
      def key
        options.fetch(:key, name)
      end

      # @return [ActiveModel::Serializer, nil]
      def serializer
        options[:serializer]
      end

      # @return [Hash]
      def links
        options.fetch(:links) || {}
      end

      # @return [Hash, nil]
      def meta
        options[:meta]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
active_model_serializers-0.10.5 lib/active_model/serializer/association.rb
active_model_serializers-0.10.4 lib/active_model/serializer/association.rb
agi_active_model_serializers-0.10.9 lib/active_model/serializer/association.rb
agi_active_model_serializers-0.10.8 lib/active_model/serializer/association.rb
agi_active_model_serializers-0.10.7 lib/active_model/serializer/association.rb
active_model_serializers-0.10.3 lib/active_model/serializer/association.rb