Sha256: e7ed2a5564909446e768d068dc52dc29c947c8620c66fdca731580452c829315

Contents?: true

Size: 813 Bytes

Versions: 104

Compression:

Stored size: 813 Bytes

Contents

module BulletTrain
  module Api
    module Attributes
      # We default this to the current version of the API, but developers can request a specific version.
      def api_attributes(api_version = BulletTrain::Api.current_version_numeric)
        controller = "Api::V#{api_version}::ApplicationController".constantize.new
        # TODO We need to fix host names here.
        controller.request = ActionDispatch::Request.new({})
        local_class_key = self.class.name.underscore.split("/").last.to_sym

        # Returns a hash, not string.
        JbuilderTemplate.new(controller.view_context) do |json|
          json.partial! "api/#{BulletTrain::Api.current_version}/#{self.class.name.underscore.pluralize}/#{local_class_key}", local_class_key => self
        end.attributes!
      end
    end
  end
end

Version data entries

104 entries across 104 versions & 1 rubygems

Version Path
bullet_train-api-1.3.13 lib/bullet_train/api/attributes.rb
bullet_train-api-1.3.12 lib/bullet_train/api/attributes.rb
bullet_train-api-1.3.11 lib/bullet_train/api/attributes.rb
bullet_train-api-1.3.10 lib/bullet_train/api/attributes.rb