Sha256: 5d6a2f8d3219a8aee8ef5b61d4f481ddc9cd41c7980a8c4dc95c19e907171bd3

Contents?: true

Size: 697 Bytes

Versions: 1

Compression:

Stored size: 697 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

1 entries across 1 versions & 1 rubygems

Version Path
orange-more-0.5.8 lib/orange-more/administration/middleware/site_load.rb