Class: Orange::Middleware::SiteLoad

Inherits:
Base
  • Object
show all
Defined in:
lib/orange-more/administration/middleware/site_load.rb

Overview

This will load information about the site to into the orange env

  • packet will be an instance of the site object

Instance Method Summary collapse

Instance Method Details

#packet_call(packet) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/orange-more/administration/middleware/site_load.rb', line 7

def packet_call(packet)
  url =  packet['route.site_url']
  site = OrangeSite.first(:url.like => url)
  if site
    packet['site'] = site
  elsif orange.options[:development_mode] || OrangeSite.all.size == 0
    s = OrangeSite.new({:url => packet['route.site_url'], 
                          :name => 'An Orange Site'})
    s.save
    packet['site'] = s
  else
    packet['site'] = OrangeSite.first
  end
  pass packet
end