Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support YARD notation #724

Merged
merged 10 commits into from
Jan 24, 2020
22 changes: 11 additions & 11 deletions lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,17 @@ def classified_sort(cols)
([id] << rest_cols << timestamps << associations).flatten.compact
end

def map_col_type_to_ruby_classes(col_type)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - can you elaborate why it should not be private and public instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know, my first idea was that it can be reused somewhere else but seems not yet so i'll add it in private

case col_type
when 'integer' then Integer.to_s
when 'float' then Float.to_s
when 'decimal' then BigDecimal.to_s
when 'datetime', 'timestamp', 'time' then Time.to_s
when 'date' then Date.to_s
when 'text', 'string', 'binary', 'inet', 'uuid' then String.to_s
when 'json', 'jsonb' then Hash.to_s
end
end
private

def with_comments?(klass, options)
Expand Down Expand Up @@ -949,17 +960,6 @@ def non_ascii_length(string)
end
end

def map_col_type_to_ruby_classes(col_type)
case col_type
when 'integer' then Integer.to_s
when 'float' then Float.to_s
when 'decimal' then BigDecimal.to_s
when 'datetime', 'timestamp', 'time' then Time.to_s
when 'date' then Date.to_s
when 'text', 'string', 'binary', 'inet', 'uuid' then String.to_s
when 'json', 'jsonb' then Hash.to_s
end
end
class BadModelFileError < LoadError
def to_s
"file doesn't contain a valid model class"
Expand Down