Skip to content

Commit 124a1a9

Browse files
Enum as proc
Enums can be dynamic like aasm_state or items in database, so if representer have documentation with calls to db it will affect speed of representer. It is better to have proc to defer reading enum property. Now that I think about this. It will be better to documentation property as proc. What do you think?
1 parent 433a020 commit 124a1a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/grape-swagger/representable/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def parse_representer_property(property)
4242
end
4343

4444
values = documentation[:values] || property[:values] || nil
45-
memo[:enum] = values if values.is_a?(Array)
45+
memo[:enum] = values.is_a?(Proc) ? values.call : values if values
4646

4747
example = documentation[:example] || property[:example] || nil
4848
memo[:example] = example.is_a?(Proc) ? example.call : example if example

0 commit comments

Comments
 (0)