Sha256: fd372d63b505a24eda4c4a965772eef17d3a8c1f7963b66c1cb470ed7dba8868

Contents?: true

Size: 754 Bytes

Versions: 10

Compression:

Stored size: 754 Bytes

Contents

module ActiveModel
  class Serializer
    module Meta
      extend ActiveSupport::Concern

      included do
        with_options instance_writer: false, instance_reader: true do |serializer|
          serializer.class_attribute :_meta # @api private
        end

        extend ActiveSupport::Autoload
      end

      module ClassMethods
        # Set the JSON API meta attribute of a serializer.
        # @example
        #   class AdminAuthorSerializer < ActiveModel::Serializer
        #     meta { stuff: 'value' }
        # @example
        #     meta do
        #       { comment_count: object.comments.count }
        #     end
        def meta(value = nil, &block)
          self._meta = block || value
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
active_model_serializers-0.10.5 lib/active_model/serializer/concerns/meta.rb
active_model_serializers-0.10.4 lib/active_model/serializer/concerns/meta.rb
agi_active_model_serializers-0.10.9 lib/active_model/serializer/concerns/meta.rb
agi_active_model_serializers-0.10.8 lib/active_model/serializer/concerns/meta.rb
agi_active_model_serializers-0.10.7 lib/active_model/serializer/concerns/meta.rb
active_model_serializers-0.10.3 lib/active_model/serializer/concerns/meta.rb
active_model_serializers-0.10.2 lib/active_model/serializer/meta.rb
active_model_serializers-0.10.1 lib/active_model/serializer/meta.rb
active_model_serializers-0.10.0 lib/active_model/serializer/meta.rb
active_model_serializers-0.10.0.rc5 lib/active_model/serializer/meta.rb