Class: Blueprint::StructuralElementDesignContext

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

Instance Method Summary collapse

Methods inherited from DesignContext

#check_rules, #determine_remote_repository, #send

Constructor Details

#initialize(api_key, structure_id, name, code_url) ⇒ StructuralElementDesignContext

Returns a new instance of StructuralElementDesignContext.



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/blueprint/api/rails.rb', line 272

def initialize(api_key, structure_id, name, code_url)
  @api_key = api_key
  @structure_id = structure_id
  @instance_id = SecureRandom.uuid
  @name = name
  @code_url = code_url

  # 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

  # we register the structural element immediately (so that it appears on the structure even though it has no description / messages)
  self.send DESCRIBE_ELEMENT,
            {
                :name => @name,
                :code_url => @code_url
            }
end

Instance Method Details

#contains(constituent) ⇒ Object



313
314
315
316
317
318
319
320
# File 'lib/blueprint/api/rails.rb', line 313

def contains(constituent)
  self.send CONTAINS,
            {
                :parent => @name,
                :constituent => constituent
            }
  self
end

#contains_with_pattern(pattern) ⇒ Object



304
305
306
307
308
309
310
311
# File 'lib/blueprint/api/rails.rb', line 304

def contains_with_pattern(pattern)
  self.send CONTAINS,
            {
                :parent => @name,
                :pattern => pattern
            }
  self
end

#describe(description = nil, stereotype = nil) ⇒ Object

applies a description to the (structural) element



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

def describe(description = nil, stereotype = nil)
  self.send DESCRIBE_ELEMENT,
            {
                :name => @name,
                :description => description,
                :stereotype => stereotype
            }
  self
end