Method: ContextHelp::Base.help_path_for

Defined in:
lib/context_help/base.rb

.help_path_for(options, register = true) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/context_help/base.rb', line 65

def self.help_path_for(options,register=true)
  path = options[:path]
  return path if path.is_a?(String)

  ruta = nil
  if !options[:skip]
    if path[:model] and @config[:exclude_models].index(path[:model].to_sym).nil?
      ruta = 'context_help.models.'+Helpers.model_name(path[:model])
      options[:pre_level_class] = @config[:level_classes][:model]
      
      if (path[:attribute])
        ruta = ruta + '.attributes.'+ path[:attribute].to_s.underscore
        options[:pre_level_class] = @config[:level_classes][:model_attribute]
      end  
    elsif path[:custom]
      ruta = 'context_help.custom.'+path[:custom]
      options[:pre_level_class] = @config[:level_classes][:custom]
    elsif path[:tag] and @config[:exclude_tags].index(path[:tag].to_sym).nil?
      ruta = 'context_help.html.'+path[:tag].to_s.downcase
      ruta = ruta + '.' + path[:tag_options][:id].to_s if path[:tag_options][:id]
      
      if @config[:level_classes][:html].include?(path[:tag])
        options[:pre_level_class] = @config[:level_classes][:html][path[:tag]]
      else
        options[:pre_level_class] = @config[:level_classes][:html][:default]
      end
    end
  end
  if ruta              
    options[:calculated_path] = ruta
    self.register_item(options) if register
    return options[:calculated_path]
  end
  nil
end