Sha256: 097a135e3382c33161a2d7a7f5e5bcb73aae4e63d5abf9fc104985541b88f173

Contents?: true

Size: 866 Bytes

Versions: 8

Compression:

Stored size: 866 Bytes

Contents

# frozen_string_literal: true

module ActiveModelSerializers
  module Adapter
    class JsonApi
      # meta
      # definition:
      #   JSON Object
      #
      # description:
      #   Non-standard meta-information that can not be represented as an attribute or relationship.
      # structure:
      #   {
      #     attitude: 'adjustable'
      #   }
      class Meta
        def initialize(serializer)
          @object = serializer.object
          @scope = serializer.scope

          # Use the return value of the block unless it is nil.
          if serializer._meta.respond_to?(:call)
            @value = instance_eval(&serializer._meta)
          else
            @value = serializer._meta
          end
        end

        def as_json
          @value
        end

        protected

        attr_reader :object, :scope
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
active_model_serializers-0.10.15 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.14 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.13 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.12 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.11 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.10 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers_custom-0.10.90 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.9 lib/active_model_serializers/adapter/json_api/meta.rb