Class: EacRailsUtils::LinksHelper::ObjectPath

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/eac_rails_utils/links_helper/object_path.rb

Instance Method Summary collapse

Instance Method Details

#resultObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/eac_rails_utils/links_helper/object_path.rb', line 9

def result
  current_class = object_class(object)
  tried_paths = []
  while current_class
    path = object_path_by_class(current_class, action)
    return view.send(path, object) if view.respond_to?(path)

    tried_paths << path
    current_class = current_class.superclass
  end
  raise "Path not found for {object: #{object.class}, action: \"#{action}\"}" \
        "(Tried: #{tried_paths})"
end