rails-annotate-solargraph 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/rails/annotate/solargraph/model.rb +24 -6
- data/lib/rails/annotate/solargraph/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d62415c07dd7235a4151593d2def72a55a7f8b7f7785f71eb66fe6996ce657d
|
4
|
+
data.tar.gz: a4737b994cb8ece0516da3d2e57ba66e05a5243cfc29ad1149f99bb03e1f8d1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b67bd482cf97936d6b55a9c28b5845a45a53650683cc05a89823427573aee2d66ac9500147b53c8b18ab74c6883f3f3306db864341aa03344ca5c376a6173892
|
7
|
+
data.tar.gz: 96d4d8aff31ee3a530635959539483572c268164c0214701e7b286cbcde37069419752ea3fd5b0bf466d5480dcdb4637f97952f764b932ea2824b8a14ec025c5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -15,6 +15,18 @@ module Rails
|
|
15
15
|
# @return [Regexp]
|
16
16
|
MAGIC_COMMENT_REGEXP = /(^#\s*encoding:.*(?:\n|r\n))|(^# coding:.*(?:\n|\r\n))|(^# -\*- coding:.*(?:\n|\r\n))|(^# -\*- encoding\s?:.*(?:\n|\r\n))|(^#\s*frozen_string_literal:.+(?:\n|\r\n))|(^# -\*- frozen_string_literal\s*:.+-\*-(?:\n|\r\n))/.freeze
|
17
17
|
|
18
|
+
class << (FAKE_MODEL_CLASS = Object.new)
|
19
|
+
def to_s
|
20
|
+
::Object.to_s
|
21
|
+
end
|
22
|
+
|
23
|
+
alias name to_s
|
24
|
+
|
25
|
+
def table_name
|
26
|
+
'<unknown>'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
18
30
|
class << self
|
19
31
|
# @param type [Symbol, String, nil]
|
20
32
|
# @return [String]
|
@@ -147,17 +159,23 @@ module Rails
|
|
147
159
|
# @param reflection [ActiveRecord::Reflection::AbstractReflection]
|
148
160
|
# @return [void]
|
149
161
|
def document_relation(doc_string, attr_name, reflection)
|
162
|
+
reflection_class = begin
|
163
|
+
reflection.klass
|
164
|
+
rescue ::NameError
|
165
|
+
FAKE_MODEL_CLASS
|
166
|
+
end
|
167
|
+
|
150
168
|
db_description = \
|
151
169
|
case reflection
|
152
170
|
when ::ActiveRecord::Reflection::BelongsToReflection
|
153
|
-
type_docstring =
|
154
|
-
"`belongs_to` relation with `#{
|
171
|
+
type_docstring = reflection_class
|
172
|
+
"`belongs_to` relation with `#{reflection_class}`. Database column `#{@klass.table_name}.#{reflection.foreign_key}`."
|
155
173
|
when ::ActiveRecord::Reflection::HasOneReflection
|
156
|
-
type_docstring =
|
157
|
-
"`has_one` relation with `#{
|
174
|
+
type_docstring = reflection_class
|
175
|
+
"`has_one` relation with `#{reflection_class}`. Database column `#{reflection_class.table_name}.#{reflection.foreign_key}`."
|
158
176
|
when ::ActiveRecord::Reflection::HasManyReflection
|
159
|
-
type_docstring = "Array<#{
|
160
|
-
"`has_many` relation with `#{
|
177
|
+
type_docstring = "Array<#{reflection_class}>"
|
178
|
+
"`has_many` relation with `#{reflection_class}`. Database column `#{reflection_class.table_name}.#{reflection.foreign_key}`."
|
161
179
|
end
|
162
180
|
|
163
181
|
doc_string << <<~DOC
|