module Doorkeeper::Orm::ActiveRecord::Mixins::Application

def as_json(options = {})

Returns:
  • (Hash) - entity attributes for JSON
def as_json(options = {})
  # if application belongs to some owner we need to check if it's the same as
  # the one passed in the options or check if we render the client as an owner
  if (respond_to?(:owner) && owner && owner == options[:current_resource_owner]) ||
     options[:as_owner]
    # Owners can see all the client attributes, fallback to ActiveModel serialization
    super
  else
    # if application has no owner or it's owner doesn't match one from the options
    # we render only minimum set of attributes that could be exposed to a public
    only = extract_serializable_attributes(options)
    super(options.merge(only: only))
  end
end