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 conern 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.
23 24 25 |
# File 'app/helpers/workbench/object_helper.rb', line 23 def collection_base_path(object) object.class.name.tableize end |
#helper_module(object) ⇒ Object
Given the object (non metamorphosized), return the helper instance
28 29 30 |
# File 'app/helpers/workbench/object_helper.rb', line 28 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.
17 18 19 |
# File 'app/helpers/workbench/object_helper.rb', line 17 def member_base_path(object) object.class.name.tableize.singularize end |
#metamorphosize_if(object) ⇒ ActiveRecord object
Returns metamorphosize is defined in the conern Shared::IsData, if its available use it on the object.
7 8 9 10 11 12 13 |
# File 'app/helpers/workbench/object_helper.rb', line 7 def (object) if object.respond_to?(:metamorphosize) object. else object end end |