Class: Qdocs::ActiveRecord::Method
- Inherits:
-
Base::Method
- Object
- Base::Method
- Qdocs::ActiveRecord::Method
- Includes:
- Helpers
- Defined in:
- lib/qdocs/active_record.rb
Instance Method Summary collapse
Methods included from Helpers
#active_record_attributes_for, #if_active_record
Methods inherited from Base::Method
Methods included from Helpers
#find_constant, #own_methods, #params_to_hash, #render_response, #source_location_to_str
Constructor Details
This class inherits a constructor from Qdocs::Base::Method
Instance Method Details
#index(const, pattern) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# 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) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# 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 |