Class: Blueprint::LinkDesignContext

Inherits:
DesignContext show all
Defined in:
lib/blueprint/api/rails.rb

Instance Method Summary collapse

Methods inherited from DesignContext

#send

Constructor Details

#initialize(api_key, structure_id, source, target) ⇒ LinkDesignContext



334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/blueprint/api/rails.rb', line 334

def initialize(api_key, structure_id, source, target)
  @api_key = api_key
  @structure_id = structure_id
  @source = source
  @target = target
  @branch = `git rev-parse --abbrev-ref HEAD 2>&1`.strip! || 'master'

  # initialise faraday
  @conn = Faraday.new(:url => BLUEPRINT_SERVER) do |faraday|
    # faraday.response :logger                  # log requests to STDOUT
    faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
  end
end

Instance Method Details

#log(message = { }, extras = { }, type = nil) ⇒ Object

logs a message between two nodes in the structure



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/blueprint/api/rails.rb', line 349

def log(message = { }, extras = { }, type = nil)
  properties = Hash.new.tap do |h|
    h[:source] = @source unless @source.blank?
    h[:target] = @target unless @target.blank?
  end

  payload = Hash.new.tap do |h|
    h[:type] = type unless type.blank?
    h[:payload] = {
        :message => message,
        :extras => extras
    }
  end

  self.send MESSAGE, properties, payload

  # return nil so that no further calls can be made to the fluent API
  nil
end