class Qdocs::ActiveRecord::Method

Public Instance Methods

index(const, pattern) click to toggle source
Calls superclass method Qdocs::Base::Method#index
# File lib/qdocs/active_record.rb, line 62
def index(const, pattern)
  database_attributes = {}
  attrs = super do |constant|
    if_active_record(constant) do |klass|
      klass.columns.each do |col|
        next unless col.name.to_s.match? pattern

        database_attributes[col.name.to_sym] = active_record_attributes_for col
      end
    end
  end

  if database_attributes.empty?
    attrs
  else
    {
      **attrs,
      attributes: {
        **attrs[:attributes],
        database_attributes: database_attributes,
      },
    }
  end
end
show(const, meth, type) click to toggle source
Calls superclass method Qdocs::Base::Method#show
# File lib/qdocs/active_record.rb, line 87
def show(const, meth, type)
  constant = []
  super do |klass|
    constant << klass
  end
rescue UnknownMethodError => e
  if constant[0] && meth && type == :instance
    if_active_record(constant[0]) do |klass|
      m = meth.is_a?(::Method) ? (meth.name rescue nil) : meth
      return render_response(
               klass,
               :active_record_attribute,
               active_record_attributes_for(klass.column_for_attribute(m))
             )
    end
  end

  raise e
end