Class: ActiveElement::RailsComponent

Inherits:
Object
  • Object
show all
Defined in:
lib/active_element/rails_component.rb

Overview

Abstraction of various Rails interfaces.

Instance Method Summary collapse

Constructor Details

#initialize(rails) ⇒ RailsComponent

Returns a new instance of RailsComponent.



6
7
8
# File 'lib/active_element/rails_component.rb', line 6

def initialize(rails)
  @rails = rails
end

Instance Method Details

#application_nameObject



18
19
20
# File 'lib/active_element/rails_component.rb', line 18

def application_name
  rails.application.class.module_parent.name.underscore
end

#environmentObject



14
15
16
# File 'lib/active_element/rails_component.rb', line 14

def environment
  rails.env
end

#route_paths_with_requirementsObject

Provides array of e.g. { path: “/admin/users”, controller: “admin/users”, action: “index” }



23
24
25
26
27
# File 'lib/active_element/rails_component.rb', line 23

def route_paths_with_requirements
  rails.application.routes.routes.map do |route|
    { path: path_from_route_spec(route.path.spec) }.merge(route.requirements)
  end
end

#routesObject



10
11
12
# File 'lib/active_element/rails_component.rb', line 10

def routes
  rails.application.routes
end