Module: Recourse::Recoursive
- Defined in:
- lib/recourse/model/recoursive.rb
Overview
Ensures every Active Record object is compatible with recourse.
Instance Method Summary collapse
-
#recourse_actions ⇒ Object
Return the actions available for the model (among :new, :edit, :destroy).
-
#recourse_cachable? ⇒ Boolean
Return whether the content to display all the models can be cached.
-
#recourse_includes ⇒ Object
Return the associations to .include when loading all the resources.
-
#recourse_order ⇒ Object
Return the fields to .order when loading all the models.
-
#recourse_positionable? ⇒ Boolean
Return whether the model has a position field to use for drag’n’drop sorting.
-
#recourse_searchable? ⇒ Boolean
Whether Ransack attributes are defined on the resource.
Instance Method Details
#recourse_actions ⇒ Object
Return the actions available for the model (among :new, :edit, :destroy)
11 12 13 14 15 |
# File 'lib/recourse/model/recoursive.rb', line 11 def recourse_actions default = %i[new edit destroy] = Recourse.resources[name.underscore.pluralize.to_sym] (Array(.fetch :only, default) & default) - Array(.fetch :except, []) end |
#recourse_cachable? ⇒ Boolean
Return whether the content to display all the models can be cached.
22 23 24 |
# File 'lib/recourse/model/recoursive.rb', line 22 def recourse_cachable? true end |
#recourse_includes ⇒ Object
Return the associations to .include when loading all the resources.
6 7 8 |
# File 'lib/recourse/model/recoursive.rb', line 6 def recourse_includes %i[] end |
#recourse_order ⇒ Object
Return the fields to .order when loading all the models.
18 19 |
# File 'lib/recourse/model/recoursive.rb', line 18 def recourse_order end |
#recourse_positionable? ⇒ Boolean
Return whether the model has a position field to use for drag’n’drop sorting.
27 28 29 |
# File 'lib/recourse/model/recoursive.rb', line 27 def recourse_positionable? false end |
#recourse_searchable? ⇒ Boolean
Returns whether Ransack attributes are defined on the resource.
32 33 34 |
# File 'lib/recourse/model/recoursive.rb', line 32 def recourse_searchable? ransackable_attributes.any? || ransortable_attributes.any? end |