Sha256: 09fce47d75f8d4d94118e033d03b432d38b5b22a7025ec9c08430b484aff0bd4

Contents?: true

Size: 841 Bytes

Versions: 30

Compression:

Stored size: 841 Bytes

Contents

module JsonapiCompliable
  module Util
    # Generate the options we end up passing to {{http://jsonapi-rb.org jsonapi-rb}}
    # @api private
    class RenderOptions
      def self.generate(object, query_hash, overrides = {})
        resolved = object.respond_to?(:resolve) ? object.resolve : object

        options            = {}
        options[:include]  = query_hash[:include]
        options[:jsonapi]  = resolved
        options[:fields]   = query_hash[:fields]
        options.merge!(overrides)
        options[:meta]   ||= {}
        options[:expose] ||= {}
        options[:expose][:extra_fields] = query_hash[:extra_fields]

        if object.respond_to?(:resolve_stats)
          stats = object.resolve_stats
          options[:meta][:stats] = stats unless stats.empty?
        end

        options
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
jsonapi_compliable-0.10.9 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.10.7 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.10.6 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.10.5 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.10.4 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.10.3 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.10.2 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.10.1 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.10.0 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.9.2 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.9.1 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.9.0 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.8.0 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.7.9 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.7.8 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.7.7 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.7.6 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.7.5 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.7.4 lib/jsonapi_compliable/util/render_options.rb
jsonapi_compliable-0.7.3 lib/jsonapi_compliable/util/render_options.rb