Class: Excursion::Pool::Application
- Inherits:
-
Object
- Object
- Excursion::Pool::Application
- Defined in:
- lib/excursion/pool/application.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#default_url_options ⇒ Object
readonly
Returns the value of attribute default_url_options.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #from_cache(cached) ⇒ Object
- #route(key) ⇒ Object
- #routes ⇒ Object
- #routes=(routes) ⇒ Object
- #set_routes(routes) ⇒ Object
- #to_cache ⇒ Object
Instance Attribute Details
#default_url_options ⇒ Object (readonly)
Returns the value of attribute default_url_options.
4 5 6 |
# File 'lib/excursion/pool/application.rb', line 4 def @default_url_options end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/excursion/pool/application.rb', line 4 def name @name end |
Class Method Details
.from_cache(cached) ⇒ Object
6 7 8 |
# File 'lib/excursion/pool/application.rb', line 6 def self.from_cache(cached) new(cached[:name], cached) unless cached.nil? end |
Instance Method Details
#from_cache(cached) ⇒ Object
40 41 42 43 44 |
# File 'lib/excursion/pool/application.rb', line 40 def from_cache(cached) @routes = routes_from_cache(cached[:routes]) if cached.has_key?(:routes) @default_url_options = cached[:default_url_options] @registered_at = (Time.at(cached[:registered_at]) rescue Time.now) end |
#route(key) ⇒ Object
10 11 12 |
# File 'lib/excursion/pool/application.rb', line 10 def route(key) routes[key.to_sym] end |
#routes ⇒ Object
14 15 16 |
# File 'lib/excursion/pool/application.rb', line 14 def routes @routes ||= ActionDispatch::Routing::RouteSet::NamedRouteCollection.new end |
#routes=(routes) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/excursion/pool/application.rb', line 18 def routes=(routes) return @routes = routes if routes.is_a?(ActionDispatch::Routing::RouteSet::NamedRouteCollection) raise ArgumentError, 'routes must be a Hash or NamedRouteCollection' unless routes.is_a?(Hash) @routes = ActionDispatch::Routing::RouteSet::NamedRouteCollection.new routes.each do |name, route| @routes.add(name, route) end end |
#set_routes(routes) ⇒ Object
27 28 29 |
# File 'lib/excursion/pool/application.rb', line 27 def set_routes(routes) self.routes = routes end |
#to_cache ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/excursion/pool/application.rb', line 31 def to_cache { name: @name, routes: Hash[routes.map { |name, route| [name.to_sym, route.path.spec.to_s] }], default_url_options: @default_url_options, registered_at: @registered_at } end |