Module: FastAPIExtension::ClassMethods
- Defined in:
- lib/fastapi/active_record_extension.rb
Instance Method Summary collapse
- #fastapi ⇒ Object
- #fastapi_custom_order ⇒ Object
-
#fastapi_default_filters(filters) ⇒ Hash
Used to set any default filters for the top level fastapi response.
-
#fastapi_define_order(keys) ⇒ Hash
Define custom ORDER BY strings for specific keys.
- #fastapi_fields ⇒ Object
- #fastapi_fields_sub ⇒ Object
- #fastapi_filters ⇒ Object
- #fastapi_filters_whitelist ⇒ Object
-
#fastapi_safe_fields(fields) ⇒ Array
Set safe fields for FastAPIInstance.safe_filter These are the fields that can be actively filtered by.
-
#fastapi_standard_interface(fields) ⇒ Array
Used to set the standard interface for the top level of a fastapi response.
-
#fastapi_standard_interface_nested(fields) ⇒ Array
Used to set the standard interface for the second level of a fastapi response (nested).
Instance Method Details
#fastapi ⇒ Object
70 71 72 |
# File 'lib/fastapi/active_record_extension.rb', line 70 def fastapi FastAPI.new(self) end |
#fastapi_custom_order ⇒ Object
50 51 52 |
# File 'lib/fastapi/active_record_extension.rb', line 50 def fastapi_custom_order @fastapi_custom_order || {} end |
#fastapi_default_filters(filters) ⇒ Hash
Used to set any default filters for the top level fastapi response
38 39 40 |
# File 'lib/fastapi/active_record_extension.rb', line 38 def fastapi_default_filters(filters) @fastapi_filters = filters end |
#fastapi_define_order(keys) ⇒ Hash
Define custom ORDER BY strings for specific keys
46 47 48 |
# File 'lib/fastapi/active_record_extension.rb', line 46 def fastapi_define_order(keys) @fastapi_custom_order = keys end |
#fastapi_fields ⇒ Object
54 55 56 |
# File 'lib/fastapi/active_record_extension.rb', line 54 def fastapi_fields @fastapi_fields || [:id] end |
#fastapi_fields_sub ⇒ Object
58 59 60 |
# File 'lib/fastapi/active_record_extension.rb', line 58 def fastapi_fields_sub @fastapi_fields_sub || [:id] end |
#fastapi_filters ⇒ Object
66 67 68 |
# File 'lib/fastapi/active_record_extension.rb', line 66 def fastapi_filters @fastapi_filters || {} end |
#fastapi_filters_whitelist ⇒ Object
62 63 64 |
# File 'lib/fastapi/active_record_extension.rb', line 62 def fastapi_filters_whitelist @fastapi_filters_whitelist || @fastapi_fields || [:id] end |
#fastapi_safe_fields(fields) ⇒ Array
Set safe fields for FastAPIInstance.safe_filter These are the fields that can be actively filtered by
30 31 32 |
# File 'lib/fastapi/active_record_extension.rb', line 30 def fastapi_safe_fields(fields) @fastapi_filters_whitelist = fields end |
#fastapi_standard_interface(fields) ⇒ Array
Used to set the standard interface for the top level of a fastapi response
13 14 15 |
# File 'lib/fastapi/active_record_extension.rb', line 13 def fastapi_standard_interface(fields) @fastapi_fields = fields end |
#fastapi_standard_interface_nested(fields) ⇒ Array
Used to set the standard interface for the second level of a fastapi response (nested)
21 22 23 |
# File 'lib/fastapi/active_record_extension.rb', line 21 def fastapi_standard_interface_nested(fields) @fastapi_fields_sub = fields end |