Module: Faalis::Generators::Concerns::ResourceName

Included in:
DashboardScaffold
Defined in:
lib/faalis/generators/concerns/resource_name.rb

Overview

Adds the name key to json file which specify the resource name.

Instance Method Summary (collapse)

Instance Method Details

- (Object) resource (private)

Camelized resource name. you can think of it as model name



28
29
30
31
32
33
34
# File 'lib/faalis/generators/concerns/resource_name.rb', line 28

def resource
  path_parts = resource_data["name"].split("/")
  if path_parts.length > 1
    return path_parts[-1].camelize
  end
  resource_data["name"].camelize
end

- (Object) resource_path (private)

Path to the resource



10
11
12
13
14
15
16
# File 'lib/faalis/generators/concerns/resource_name.rb', line 10

def resource_path
  path_parts = resource_data["name"].split("/")
  if path_parts.length > 1
    return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].underscore}"
  end
  resource_data["name"].underscore
end

- (Object) resource_url (private)

Url of resource



19
20
21
22
23
24
25
# File 'lib/faalis/generators/concerns/resource_name.rb', line 19

def resource_url
  path_parts = resource_data["name"].split("/")
  if path_parts.length > 1
    return "#{path_parts(0..-2).join("/")}/#{path_parts[-1].pluralize.underscore}"
  end
  resource_data["name"].pluralize.underscore
end