Class: Veracode::Common::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/veracode/api/types.rb

Overview

Base Class for result

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml_hash) ⇒ Base

Takes Hash of XML stores, hash is has addition to allow dot access to components



34
35
36
# File 'lib/veracode/api/types.rb', line 34

def initialize(xml_hash)
  @xml_hash = xml_hash
end

Class Method Details

.api_field(name, args) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/veracode/api/types.rb', line 11

def self.api_field(name, args)  
  send(:define_method, name) do   
    begin
      return @xml_hash.send(args[:tag].to_sym)
    rescue NoMethodError
      return nil
    end
  end
end

.api_type_field(name, args) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/veracode/api/types.rb', line 21

def self.api_type_field(name, args)
  send(:define_method, name) do
    begin
      tmp = eval("@" + name.to_s)  
      tmp ||= args[:as].new(@xml_hash.send(args[:tag].to_sym))
      instance_variable_set("@#{name}", tmp) 
      return tmp
    rescue NoMethodError
      return nil
    end
  end   
end