Class: Pivotal::Base

Inherits:
Object
  • Object
show all
Includes:
Associations, Attributes
Defined in:
lib/pivotal/base.rb

Direct Known Subclasses

Api, Project, Story

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Attributes

included

Methods included from Associations

included

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



13
14
15
16
17
# File 'lib/pivotal/base.rb', line 13

def initialize(params = {})
  params.each do |key, value|
    send("#{key}=", value)
  end
end

Instance Attribute Details

#resourceObject

Returns the value of attribute resource.



11
12
13
# File 'lib/pivotal/base.rb', line 11

def resource
  @resource
end

#xmlObject

Returns the value of attribute xml.



11
12
13
# File 'lib/pivotal/base.rb', line 11

def xml
  @xml
end

Class Method Details

.name_as_xml_attributeObject



43
44
45
# File 'lib/pivotal/base.rb', line 43

def name_as_xml_attribute
  self.name.gsub(/.+\:\:/, '').downcase
end

.xpathObject



47
48
49
# File 'lib/pivotal/base.rb', line 47

def xpath
  '//' + self.name_as_xml_attribute
end

Instance Method Details

#parsed_resourceObject



23
24
25
# File 'lib/pivotal/base.rb', line 23

def parsed_resource
  @parsed_resource ||= Nokogiri::XML(xml)
end

#update_attributes(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pivotal/base.rb', line 27

def update_attributes(options = {})
  begin
    resource.put generate_xml(options) do |response|
      if response.code == 200
        @xml = response.body
        return true
      else
        return false
      end
    end
  rescue RestClient::Exception
    return false
  end
end