Class: ActionController::Base

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

Defined Under Namespace

Classes: SubdomainboxDomainViolation

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_subdomainbox(box_definitions) ⇒ Object



15
16
17
# File 'lib/subdomainbox/subdomainbox.rb', line 15

def self.default_subdomainbox(box_definitions)
  before_filter(lambda { default_subdomainbox(box_definitions) }, {})
end

.remove_default_subdomainbox(options = {}) ⇒ Object



11
12
13
# File 'lib/subdomainbox/subdomainbox.rb', line 11

def self.remove_default_subdomainbox(options={})
  prepend_before_filter(:remove_default_subdomainbox, options)
end

.subdomainbox(box_definitions, options = {}) ⇒ Object



7
8
9
# File 'lib/subdomainbox/subdomainbox.rb', line 7

def self.subdomainbox(box_definitions, options={})
  prepend_before_filter(lambda { subdomainbox(box_definitions) }, options)
end

Instance Method Details

#default_subdomainbox(box_definitions) ⇒ Object

set up a default subdomain box for all controllers that won’t get an explicit subdomain box this protects regular pages that don’t get a dedicated subdomain box from being accessed from a subdomain boxed page



37
38
39
# File 'lib/subdomainbox/subdomainbox.rb', line 37

def default_subdomainbox(box_definitions)
  subdomainbox(box_definitions) unless @default_subdomainbox_removed
end

#remove_default_subdomainboxObject

for controllers that need to be accessed from many places, that don’t need boxing protection, the default subdomain box can be removed (thereby allowing ajax calls from any subdomain)



29
30
31
# File 'lib/subdomainbox/subdomainbox.rb', line 29

def remove_default_subdomainbox
  @default_subdomainbox_removed = true
end

#subdomainbox(box_definitions) ⇒ Object



19
20
21
22
23
# File 'lib/subdomainbox/subdomainbox.rb', line 19

def subdomainbox(box_definitions)
  @default_subdomainbox_removed = true
  subdomain_match = subdomainbox_find_subdomain_match(box_definitions)
  subdomainbox_no_subdomain_match!(box_definitions) if subdomain_match.nil?
end