Class: Pivotal::Base
- Inherits:
-
Object
- Object
- Pivotal::Base
- Includes:
- Associations, Attributes
- Defined in:
- lib/pivotal/base.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
Returns the value of attribute resource.
-
#xml ⇒ Object
Returns the value of attribute xml.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Base
constructor
A new instance of Base.
- #parsed_resource ⇒ Object
- #update_attributes(options = {}) ⇒ Object
Methods included from Attributes
Methods included from Associations
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
#resource ⇒ Object
Returns the value of attribute resource.
11 12 13 |
# File 'lib/pivotal/base.rb', line 11 def resource @resource end |
#xml ⇒ Object
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_attribute ⇒ Object
43 44 45 |
# File 'lib/pivotal/base.rb', line 43 def name_as_xml_attribute self.name.gsub(/.+\:\:/, '').downcase end |
.xpath ⇒ Object
47 48 49 |
# File 'lib/pivotal/base.rb', line 47 def xpath '//' + self.name_as_xml_attribute end |
Instance Method Details
#parsed_resource ⇒ Object
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( = {}) begin resource.put generate_xml() do |response| if response.code == 200 @xml = response.body return true else return false end end rescue RestClient::Exception return false end end |