Class: Blueprint::ActivityDesignContext::StepDesignContext

Inherits:
DesignContext
  • Object
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, activity_ctx, step) ⇒ StepDesignContext

Returns a new instance of StepDesignContext.



290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/blueprint/api/rails.rb', line 290

def initialize(api_key, structure_id, activity_ctx, step)
  @api_key = api_key
  @structure_id = structure_id
  @activity_ctx = activity_ctx
  @step = step
  @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, source = nil, target = nil) ⇒ Object



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
# File 'lib/blueprint/api/rails.rb', line 305

def log(message = { }, extras = { }, type = nil, source = nil, target = nil)
  properties = Hash.new.tap do |h|
    h[:instance_id] = @activity_ctx.instance_id
    h[:activity] = @activity_ctx.name
    h[:step] = @step
    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 the parent activity context so that users can keep making calls to it to add further steps
  @activity_ctx
end