Class: Exo::Tick

Inherits:
Object
  • Object
show all
Defined in:
app/services/exo/tick.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Tick

Returns a new instance of Tick.



5
6
7
8
9
# File 'app/services/exo/tick.rb', line 5

def initialize host
  _site = Site.any_of([{hosts: host}, {main_host: host}]).first
  raise ::Exo::Site::UnknowHostError.new(host) unless _site
  self.site = SitePresenter.new _site
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'app/services/exo/tick.rb', line 3

def params
  @params
end

#requestObject

Returns the value of attribute request.



3
4
5
# File 'app/services/exo/tick.rb', line 3

def request
  @request
end

#routeObject

Returns the value of attribute route.



3
4
5
# File 'app/services/exo/tick.rb', line 3

def route
  @route
end

#siteObject

Returns the value of attribute site.



3
4
5
# File 'app/services/exo/tick.rb', line 3

def site
  @site
end

Instance Method Details

#domain_redirection?(host) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/services/exo/tick.rb', line 22

def domain_redirection?(host)
  site.main_host.to_s != host
end

#route!(request) ⇒ Object

, params



26
27
28
29
30
31
32
33
34
# File 'app/services/exo/tick.rb', line 26

def route! request #, params
  unless self.route
    Exo::PathMatcher.route_for(site.routes, request.params) do |route|
      self.route = Exo::RoutePresenter.new route
    end
    raise ::Exo::Route::UnknowPathError.new site.main_host, request.path unless route
  end
  self.route
end

#servicesObject



11
12
13
14
15
16
17
18
19
20
# File 'app/services/exo/tick.rb', line 11

def services
  unless @services
    @services = {}
    site.services.each do |m|
      @services[m.name] = m.path
    end
    @services = @services.merge Exo.instance.services
  end
  @services
end