Module: BulletTrain::Api::Attributes
- Defined in:
- lib/bullet_train/api/attributes.rb
Instance Method Summary collapse
-
#api_attributes(api_version = BulletTrain::Api.current_version_numeric) ⇒ Object
We default this to the current version of the API, but developers can request a specific version.
Instance Method Details
#api_attributes(api_version = BulletTrain::Api.current_version_numeric) ⇒ Object
We default this to the current version of the API, but developers can request a specific version.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bullet_train/api/attributes.rb', line 5 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 |