Class: Juici::Callback

Inherits:
Object
  • Object
show all
Defined in:
lib/juici/callback.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build, url) ⇒ Callback

Returns a new instance of Callback.



7
8
9
10
# File 'lib/juici/callback.rb', line 7

def initialize(build, url)
  @build = build
  @url = URI(url)
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



5
6
7
# File 'lib/juici/callback.rb', line 5

def build
  @build
end

#urlObject (readonly)

Returns the value of attribute url.



5
6
7
# File 'lib/juici/callback.rb', line 5

def url
  @url
end

Instance Method Details

#process!Object



12
13
14
15
16
17
18
19
# File 'lib/juici/callback.rb', line 12

def process!
  Net::HTTP.start(url.host, url.port) do |http|
    request = Net::HTTP::Post.new(url.request_uri)
    request.body = build.to_callback_json

    response = http.request request # Net::HTTPResponse object
  end
end