Sha256: 18653b6a62285624510880ece822b01a5fdc68acd78421dcba8fbec841431e2e

Contents?: true

Size: 835 Bytes

Versions: 13

Compression:

Stored size: 835 Bytes

Contents

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

13 entries across 13 versions & 2 rubygems

Version Path
active_model_serializers-0.10.8 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.7 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.6 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.5 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.4 lib/active_model_serializers/adapter/json_api/meta.rb
agi_active_model_serializers-0.10.9 lib/active_model_serializers/adapter/json_api/meta.rb
agi_active_model_serializers-0.10.8 lib/active_model_serializers/adapter/json_api/meta.rb
agi_active_model_serializers-0.10.7 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.3 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.2 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.1 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.0 lib/active_model_serializers/adapter/json_api/meta.rb
active_model_serializers-0.10.0.rc5 lib/active_model_serializers/adapter/json_api/meta.rb