Module: Vidibus::Subdomain::Extensions::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/vidibus/subdomain/extensions/controller.rb

Instance Method Summary collapse

Instance Method Details

#ensure_subdomain!Object

Ensures that subdomain is present



12
13
14
# File 'lib/vidibus/subdomain/extensions/controller.rb', line 12

def ensure_subdomain!
  subdomain or render(:text => "Subdomain required!", :status => :unauthorized)
end

#realmObject

Returns realm from subdomain. Currently, it is the subdomain itself.



29
30
31
# File 'lib/vidibus/subdomain/extensions/controller.rb', line 29

def realm
  subdomain.realm
end

#subdomainObject

Returns current subdomain.



17
18
19
20
21
22
23
24
25
26
# File 'lib/vidibus/subdomain/extensions/controller.rb', line 17

def subdomain
  @subdomain ||= begin
    request.host_with_port.match(/(.+)\.#{::Service.this.domain}/)
    if $1
      s = OpenStruct.new
      s.realm = $1
      s
    end
  end
end