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.
14 15 16 17 18 |
# File 'lib/pivotal/base.rb', line 14 def initialize(params = {}) params.each do |key, value| send("#{key}=", value) end end |
Instance Attribute Details
#resource ⇒ Object
Returns the value of attribute resource.
12 13 14 |
# File 'lib/pivotal/base.rb', line 12 def resource @resource end |
#xml ⇒ Object
Returns the value of attribute xml.
12 13 14 |
# File 'lib/pivotal/base.rb', line 12 def xml @xml end |
Class Method Details
.name_as_xml_attribute ⇒ Object
44 45 46 |
# File 'lib/pivotal/base.rb', line 44 def name_as_xml_attribute self.name.gsub(/.+\:\:/, '').downcase end |
.xpath ⇒ Object
48 49 50 |
# File 'lib/pivotal/base.rb', line 48 def xpath '//' + self.name_as_xml_attribute end |
Instance Method Details
#parsed_resource ⇒ Object
24 25 26 |
# File 'lib/pivotal/base.rb', line 24 def parsed_resource @parsed_resource ||= Nokogiri::XML(xml) end |
#update_attributes(options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pivotal/base.rb', line 28 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 |