Class: Blueprint::ConceptDesignContext
- Inherits:
-
DesignContext
- Object
- DesignContext
- Blueprint::ConceptDesignContext
- Defined in:
- lib/blueprint/api/rails.rb
Instance Method Summary collapse
-
#allow ⇒ Object
marks a conceptual type as allowed within the archiecture.
-
#describe(description = nil, stereotype = nil) ⇒ Object
applies a description to the (conceptual) element.
- #has_many(other) ⇒ Object
- #has_one(other) ⇒ Object
-
#initialize(api_key, structure_id, name) ⇒ ConceptDesignContext
constructor
A new instance of ConceptDesignContext.
-
#only(element) ⇒ Object
marks a conceptual type as allowed within (and only within) a structural elements.
- #related_to(relation, other) ⇒ Object
Methods inherited from DesignContext
#check_rules, #determine_remote_repository, #send
Constructor Details
#initialize(api_key, structure_id, name) ⇒ ConceptDesignContext
Returns a new instance of ConceptDesignContext.
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/blueprint/api/rails.rb', line 326 def initialize(api_key, structure_id, name) @api_key = api_key @structure_id = structure_id @instance_id = SecureRandom.uuid @name = name # 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 concept immediately (so that it appears even though it has no description / messages) self.send DESCRIBE_CONCEPT, { :name => @name } end |
Instance Method Details
#allow ⇒ Object
marks a conceptual type as allowed within the archiecture
401 402 403 404 405 406 407 408 |
# File 'lib/blueprint/api/rails.rb', line 401 def allow unless RULES.has_key?(:allowed) RULES[:allowed] = [ ] end # add the type to the allowed list RULES[:allowed] << { :name => @name } end |
#describe(description = nil, stereotype = nil) ⇒ Object
applies a description to the (conceptual) element
388 389 390 391 392 393 394 395 396 |
# File 'lib/blueprint/api/rails.rb', line 388 def describe(description = nil, stereotype = nil) self.send DESCRIBE_CONCEPT, { :name => @name, :description => description, :stereotype => stereotype } self end |
#has_many(other) ⇒ Object
373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/blueprint/api/rails.rb', line 373 def has_many(other) self.send DESCRIBE_CONCEPT, { :name => @name, :relationship => { :relation => 'has many', :other => other } } # return a design context for the 'other' concept (to support the fluent API) ConceptDesignContext.new(@api_key, @structure_id, other) end |
#has_one(other) ⇒ Object
359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'lib/blueprint/api/rails.rb', line 359 def has_one(other) self.send DESCRIBE_CONCEPT, { :name => @name, :relationship => { :relation => 'has one', :other => other } } # return a design context for the 'other' concept (to support the fluent API) ConceptDesignContext.new(@api_key, @structure_id, other) end |
#only(element) ⇒ Object
marks a conceptual type as allowed within (and only within) a structural elements
411 412 413 414 415 416 417 |
# File 'lib/blueprint/api/rails.rb', line 411 def only(element) unless RULES.has_key?(@name) RULES[@name] = { } end RULES[@name][:only] = element end |
#related_to(relation, other) ⇒ Object
345 346 347 348 349 350 351 352 353 354 355 356 357 |
# File 'lib/blueprint/api/rails.rb', line 345 def (relation, other) self.send DESCRIBE_CONCEPT, { :name => @name, :relationship => { :other => other, :relation => relation } } # return a design context for the 'other' concept (to support the fluent API) ConceptDesignContext.new(@api_key, @structure_id, other) end |