base_ext.rb 740 B

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