Sha256: c5501e1a80301d6576d40d73d1381540c13690b5bcf6bab2378aa3aafeed82cc

Contents?: true

Size: 696 Bytes

Versions: 12

Compression:

Stored size: 696 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]
        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

12 entries across 12 versions & 2 rubygems

Version Path
orange-more-0.5.7 lib/orange-more/administration/middleware/site_load.rb
orange-0.5.5 lib/orange-more/administration/middleware/site_load.rb
orange-0.5.4 lib/orange-more/administration/middleware/site_load.rb
orange-0.5.3 lib/orange-more/administration/middleware/site_load.rb
orange-0.5.2 lib/orange-more/administration/middleware/site_load.rb
orange-0.5.1 lib/orange-more/administration/middleware/site_load.rb
orange-0.4.0 lib/orange-more/administration/middleware/site_load.rb
orange-0.3.9 lib/orange-more/administration/middleware/site_load.rb
orange-0.3.8 lib/orange-more/administration/middleware/site_load.rb
orange-0.3.7 lib/orange-more/administration/middleware/site_load.rb
orange-0.3.6 lib/orange-more/administration/middleware/site_load.rb
orange-0.3.5 lib/orange-more/administration/middleware/site_load.rb