Class: Blueprint::ActivityDesignContext::StepDesignContext
- Inherits:
-
DesignContext
- Object
- DesignContext
- Blueprint::ActivityDesignContext::StepDesignContext
- Defined in:
- lib/blueprint/api/rails.rb
Instance Method Summary collapse
-
#initialize(api_key, structure_id, activity_ctx, step) ⇒ StepDesignContext
constructor
A new instance of StepDesignContext.
- #log(source = nil, target = nil, type = nil, message = { }, extras = { }) ⇒ Object
Methods inherited from DesignContext
#check_rules, #determine_remote_repository, #send
Constructor Details
#initialize(api_key, structure_id, activity_ctx, step) ⇒ StepDesignContext
Returns a new instance of StepDesignContext.
455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'lib/blueprint/api/rails.rb', line 455 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(source = nil, target = nil, type = nil, message = { }, extras = { }) ⇒ Object
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
# File 'lib/blueprint/api/rails.rb', line 470 def log(source = nil, target = nil, type = nil, = { }, extras = { }) # always check the logged message for architectural rules violations check_rules(source, target, type) 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 => , :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 |