Class: TeamCity::ElementBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/teamcity/element_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, &block) ⇒ ElementBuilder

Returns a new instance of ElementBuilder.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/teamcity/element_builder.rb', line 3

def initialize(attributes = {}, &block)
  @payload = attributes

  if block_given?
    @payload['properties'] ||= {}
    @payload['properties']['property'] ||= []

    properties = {}

    yield(properties)

    properties.each do |name, value|
      @payload['properties']['property'] << {
        :name  => name,
        :value => value
      }
    end
  end
end

Instance Method Details

#to_request_bodyObject



23
24
25
# File 'lib/teamcity/element_builder.rb', line 23

def to_request_body
  @payload.to_json
end