Class: Blueprint::StructuralElementDesignContext

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, name) ⇒ StructuralElementDesignContext

Returns a new instance of StructuralElementDesignContext.


181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/blueprint/api/rails.rb', line 181

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 structural element immediately (so that it appears on the structure even though it has no description / messages)
  self.send DESCRIBE_ELEMENT,
            {
                :name => @name
            }
end

Instance Method Details

#contains(constituent) ⇒ Object


211
212
213
214
215
216
217
218
# File 'lib/blueprint/api/rails.rb', line 211

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

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

applies a description to the (structural) element


201
202
203
204
205
206
207
208
209
# File 'lib/blueprint/api/rails.rb', line 201

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