Class: JIRA::Entity Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/jiraSOAP/entities/entity.rb

Overview

This class is abstract.

The base class for all JIRA objects that can given by the server.

TODO:

remove the need for attr_accessor by having add_attributes make the call for me, but I will need to make a YARD plugin to fix the gap in the documentation when that happens

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.attributesHash{String => Array}

Returns used by the metaclass.

Returns:

  • (Hash{String => Array})

    used by the metaclass



9
10
11
# File 'lib/jiraSOAP/entities/entity.rb', line 9

def attributes
  @attributes
end

Class Method Details

.add_attributes(attributes) ⇒ Hash

Parameters:

  • attributes (Hash)

Returns:

  • (Hash)


13
14
15
16
# File 'lib/jiraSOAP/entities/entity.rb', line 13

def add_attributes attributes
  @attributes = ancestors[1].attributes.dup
  @attributes.update attributes
end

.new_with_xml(frag) ⇒ JIRA::Entity



23
24
25
26
27
# File 'lib/jiraSOAP/entities/entity.rb', line 23

def self.new_with_xml frag
  entity = allocate
  entity.initialize_with_xml frag
  entity
end

Instance Method Details

#initialize_with_xml(frag) ⇒ Object

TODO:

put debug message through the logger

TODO:

make this faster by cutting out NokogiriDriver, but I will need to add an accessor for @element of the driver object and then need to inject the marshaling methods into Nokogiri classes



35
36
37
38
39
40
41
42
# File 'lib/jiraSOAP/entities/entity.rb', line 35

def initialize_with_xml frag
  attributes = self.class.attributes
  frag.children.each { |node|
    action = attributes[node.node_name]
    self.send action[0], (node.send *action[1..-1]) if action
    #puts "Action is #{action.inspect} for #{node.node_name}"
  }
end