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.

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.parseHash{String=>Array<Symbol,Symbol,Class*>}

Returns used by the metaclass for parsing XML.

Returns:

  • (Hash{String=>Array<Symbol,Symbol,Class*>})

    used by the metaclass for parsing XML



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

def parse
  @parse
end

Class Method Details

.add_attributes(*attributes) ⇒ nil

Parameters:

  • attributes (Array<String,Symbol,Class>)

Returns:

  • (nil)


12
13
14
15
16
17
18
19
20
21
22
# File 'lib/jiraSOAP/entities/entity.rb', line 12

def add_attributes *attributes
  superclass = ancestors[1]
  @parse = superclass.parse.dup

  attributes.each { |attribute|
    attr_accessor attribute[1]
    @parse[attribute[0]] = [:"#{attribute[1]}=", *attribute[2,2]]
    alias_method :"#{attribute[1]}?", attribute[1] if attribute[2] == :to_boolean
    #" ruby-mode parse fail
  }
end

.new_with_xml(frag) ⇒ JIRA::Entity



30
31
32
33
34
# File 'lib/jiraSOAP/entities/entity.rb', line 30

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



42
43
44
45
46
47
48
49
# File 'lib/jiraSOAP/entities/entity.rb', line 42

def initialize_with_xml frag
  attributes = self.class.parse
  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

#to_soap(node_name = nil) ⇒ Object

TODO:

soapify_for should become #to_soap and should take only the

optional argument for wrapper name, otherwise just makes its own own node with appropriate subnodes and returns that as a Handsoap document

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/jiraSOAP/entities/entity.rb', line 55

def to_soap node_name = nil
  raise NotImplementedError
end