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)

Instance Method Details

- (String) collection_base_path(object)

Returns the member path base for the object, object should be metamorphosized before passing.

Returns:

  • (String)

    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

- (Object) helper_module(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

- (String) member_base_path(object)

Returns the member path base for the object, object should be metamorphosized before passing.

Returns:

  • (String)

    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

- (ActiveRecord object) metamorphosize_if(object)

Returns metamorphosize is defined in the conern Shared::IsData, if its available use it on the object

Returns:

  • (ActiveRecord object)

    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 metamorphosize_if(object)
  if object.respond_to?(:metamorphosize) 
    object.metamorphosize
  else
    object
  end
end