Sha256: d7c89ea764a3e2fa3beae3daaf4cb43d1134da59b3e39b64013b7e3cafb80791

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

module Scales
  module Worker
    module Cache
      module Push
        include Helper::ContentTypes
        
        class << self
        
          def push(params = {})
            path = params.delete(:to)
            format, content = params.to_a.first
            raise "Don't know where to push, missing :to => '/a/path' parameter"  if path.nil?
            raise "Unknown format :#{format}"                                     if format.to_content_type.nil?
            
            publish_push(path, format)                                    
            Storage::Sync.set_content(path, content)
            content
          end
          
          private
          
          def publish_push(path, format)
            data = {
              :path   => path,
              :format => format.to_s.upcase,
              :type   => "push_#{Cache.resource_or_partial?(path)}"
            }
            Storage::Sync.connection.publish "scales_monitor_events", data.to_json
          end
        
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
scales-worker-0.0.4 lib/scales-worker/cache/push.rb
scales-worker-0.0.1.beta.2 lib/scales-worker/cache/push.rb
scales-worker-0.0.1.beta.1 lib/scales-worker/cache/push.rb