base_ext.rb 662 B

12345678910111213141516171819202122
  1. module ActiveResource
  2. class Base
  3. # Backported from ActiveResource master branch
  4. def self.headers
  5. @headers ||= {}
  6. if superclass != Object && superclass.headers
  7. @headers = superclass.headers.merge(@headers)
  8. else
  9. @headers
  10. end
  11. end
  12. # https://github.com/rails/activeresource/commit/dfef85ce8f653f75673631b2950fcdb0781c313c
  13. def self.delete(id, options = {})
  14. connection.delete(element_path(id, options), headers)
  15. end
  16. def self.build(attributes = {})
  17. attrs = self.format.decode(connection.get("#{new_element_path}", headers).body).merge(attributes)
  18. self.new(attrs)
  19. end
  20. end
  21. end