Module: Workbench::ObjectHelper
- Defined in:
- app/helpers/workbench/object_helper.rb
Overview
A metamodule- helper methods for object related manipulations in other helpers
Instance Method Summary collapse
-
#collection_base_path(object) ⇒ String
The member path base for the object, object should be metamorphosized before passing.
-
#helper_module(object) ⇒ Object
Given the object (non metamorphosized), return the helper instance.
-
#member_base_path(object) ⇒ String
The member path base for the object, object should be metamorphosized before passing.
-
#metamorphosize_if(object) ⇒ ActiveRecord object
Metamorphosize is defined in the concern Shared::IsData, if its available use it on the object.
Instance Method Details
#collection_base_path(object) ⇒ String
Returns the member path base for the object, object should be metamorphosized before passing.
22 23 24 |
# File 'app/helpers/workbench/object_helper.rb', line 22 def collection_base_path(object) object.class.name.tableize end |
#helper_module(object) ⇒ Object
Given the object (non metamorphosized), return the helper instance
27 28 29 |
# File 'app/helpers/workbench/object_helper.rb', line 27 def helper_module(object) (object.class.name + 'Helper').constantize end |
#member_base_path(object) ⇒ String
Returns the member path base for the object, object should be metamorphosized before passing.
16 17 18 |
# File 'app/helpers/workbench/object_helper.rb', line 16 def member_base_path(object) object.class.name.tableize.singularize end |
#metamorphosize_if(object) ⇒ ActiveRecord object
Returns metamorphosize is defined in the concern Shared::IsData, if its available use it on the object.
6 7 8 9 10 11 12 |
# File 'app/helpers/workbench/object_helper.rb', line 6 def (object) if object.respond_to?(:metamorphosize) object. else object end end |