Sha256: f611abe9247b51dd7d1afc12f5d217e73a53e39b98c05fd30f3b2ccc2ab2eaaf

Contents?: true

Size: 695 Bytes

Versions: 1

Compression:

Stored size: 695 Bytes

Contents

##
# Outpost::Hook
#
# Hook into Newsroom.js
module Outpost
  class Hook
    attr_accessor :data, :path
    
    def initialize(options={})
      @path = options[:path]
      @data = options[:data] || { touch: true }
    end
    
    # Publish the message
    def publish
      response = connection.post do |request|
        request.url @path
        request.params = @data
      end
      
      response
    end
        
    private
    
    def connection
      @connection ||= begin
        Faraday.new(url: Rails.application.config.node.server) do |conn|
          conn.response :json
          conn.adapter Faraday.default_adapter
        end
      end
    end
  end # Hook
end # Outpost

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
outpost-cms-0.0.3 lib/outpost/hook.rb