Module: RailsNamespacePathHelper

Defined in:
lib/rails_namespace_path_helper.rb,
lib/rails_namespace_path_helper/railtie.rb,
lib/rails_namespace_path_helper/version.rb

Defined Under Namespace

Classes: Railtie

Constant Summary collapse

VERSION =
"0.1.0"

Instance Method Summary collapse

Instance Method Details

#has_namespaced_path_pluralObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rails_namespace_path_helper.rb', line 33

def has_namespaced_path_plural
  # separate controller name from namespace
  model,namespaces = *parse_class_name

  ['url','path'].each do |tag|
    helper = "#{model.pluralize}_#{tag}"

    # short circuit if conflict
    next unless ensure_methods_available(namespaces, helper)

    # create aliases...
    define_namespace_helpers(namespaces,helper)
  end
end

#has_namespaced_path_singularObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rails_namespace_path_helper.rb', line 18

def has_namespaced_path_singular
  # separate controller name from namespace
  model,namespaces = *parse_class_name

  ['url','path'].each do |tag|
    helper = "#{model.singularize}_#{tag}"

    # short circuit if conflict      
    next unless ensure_methods_available(namespaces, helper)

    # create aliases...
    define_namespace_helpers(namespaces,helper)
  end
end

#has_namespaced_pathsObject

These helpers are declared locally on the controller to avoid conflicts



12
13
14
15
16
# File 'lib/rails_namespace_path_helper.rb', line 12

def has_namespaced_paths

  has_namespaced_path_singular
  has_namespaced_path_plural
end