Class: Uchi::Repository::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/uchi/repository/routes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repository) ⇒ Routes

Returns a new instance of Routes.



8
9
10
11
12
# File 'lib/uchi/repository/routes.rb', line 8

def initialize(repository)
  @repository = repository
  @singular = repository.controller_name.singularize
  @plural = repository.controller_name.pluralize
end

Instance Attribute Details

#pluralObject (readonly)

Returns the value of attribute plural.



6
7
8
# File 'lib/uchi/repository/routes.rb', line 6

def plural
  @plural
end

#repositoryObject (readonly)

Returns the value of attribute repository.



6
7
8
# File 'lib/uchi/repository/routes.rb', line 6

def repository
  @repository
end

#singularObject (readonly)

Returns the value of attribute singular.



6
7
8
# File 'lib/uchi/repository/routes.rb', line 6

def singular
  @singular
end

Instance Method Details

#path_for(action, **options) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/uchi/repository/routes.rb', line 14

def path_for(action, **options)
  action = action.to_sym
  case action
  when :destroy, :edit, :new, :show, :update
    singular_path_for(action, **options)
  else
    plural_path_for(action, **options)
  end
end

#root_pathObject



24
25
26
# File 'lib/uchi/repository/routes.rb', line 24

def root_path
  "/#{uchi_namespace}/"
end