Sha256: adb712503631d632d437a98baa02886ddcf7d451fd4728d6dd094e2f7947f6c2

Contents?: true

Size: 725 Bytes

Versions: 8

Compression:

Stored size: 725 Bytes

Contents

require 'orange-core/middleware/base'
module Orange::Middleware
  # This will load information about the site to into the orange env
  # - packet['site'] will be an instance of the site object 
  # 
  class SiteLoad < Base    
    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
  end
  
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
orange-more-0.7.3 lib/orange-more/administration/middleware/site_load.rb
orange-more-0.7.2 lib/orange-more/administration/middleware/site_load.rb
orange-more-0.7.1 lib/orange-more/administration/middleware/site_load.rb
orange-more-0.6.5 lib/orange-more/administration/middleware/site_load.rb
orange-more-0.6.4 lib/orange-more/administration/middleware/site_load.rb
orange-more-0.6.3 lib/orange-more/administration/middleware/site_load.rb
orange-more-0.6.2 lib/orange-more/administration/middleware/site_load.rb
orange-more-0.6.0 lib/orange-more/administration/middleware/site_load.rb