Class: ActiveElement::RailsComponent
- Inherits:
-
Object
- Object
- ActiveElement::RailsComponent
- Defined in:
- lib/active_element/rails_component.rb
Overview
Abstraction of various Rails interfaces.
Instance Method Summary collapse
- #application_name ⇒ Object
- #environment ⇒ Object
-
#initialize(rails) ⇒ RailsComponent
constructor
A new instance of RailsComponent.
-
#route_paths_with_requirements ⇒ Object
Provides array of e.g.
- #routes ⇒ Object
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_name ⇒ Object
18 19 20 |
# File 'lib/active_element/rails_component.rb', line 18 def application_name rails.application.class.module_parent.name.underscore end |
#environment ⇒ Object
14 15 16 |
# File 'lib/active_element/rails_component.rb', line 14 def environment rails.env end |
#route_paths_with_requirements ⇒ Object
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 |
#routes ⇒ Object
10 11 12 |
# File 'lib/active_element/rails_component.rb', line 10 def routes rails.application.routes end |