Class: IOSConfig::Payload::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/ios_config/payload/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Base

Returns a new instance of Base.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ios_config/payload/base.rb', line 9

def initialize(attributes = {})
  attributes ||= {}
  attributes.each do |name, value|
    begin
      send("#{name}=", value)
    rescue NoMethodError => e
      raise ArgumentError, %{"#{name}" is not a valid attribute}
    end
  end

  @uuid         ||= SecureRandom.uuid
  @identifier   ||= @uuid.downcase.delete("^a-z0-9\.")
  @description  ||= ""
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



7
8
9
# File 'lib/ios_config/payload/base.rb', line 7

def description
  @description
end

#identifierObject

Returns the value of attribute identifier.



7
8
9
# File 'lib/ios_config/payload/base.rb', line 7

def identifier
  @identifier
end

#uuidObject

Returns the value of attribute uuid.



7
8
9
# File 'lib/ios_config/payload/base.rb', line 7

def uuid
  @uuid
end

Instance Method Details

#buildObject



24
25
26
27
28
29
30
31
32
# File 'lib/ios_config/payload/base.rb', line 24

def build
  p = { 'PayloadType'         => payload_type,
        'PayloadVersion'      => payload_version,
        'PayloadUUID'         => @uuid,
        'PayloadIdentifier'   => @identifier,
        'PayloadDescription'  => @description }

  p.merge payload
end