Created
October 12, 2010 14:15
-
-
Save spastorino/622228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb | |
index b5b46d7..b47ce0e 100644 | |
--- a/activeresource/lib/active_resource/base.rb | |
+++ b/activeresource/lib/active_resource/base.rb | |
@@ -3,7 +3,6 @@ require 'active_support/core_ext/class/attribute_accessors' | |
require 'active_support/core_ext/class/inheritable_attributes' | |
require 'active_support/core_ext/hash/indifferent_access' | |
require 'active_support/core_ext/kernel/reporting' | |
-require 'active_support/core_ext/module/attr_accessor_with_default' | |
require 'active_support/core_ext/module/delegation' | |
require 'active_support/core_ext/module/aliasing' | |
require 'active_support/core_ext/object/blank' | |
@@ -563,10 +562,10 @@ module ActiveResource | |
@headers ||= {} | |
end | |
- attr_accessor_with_default(:element_name) { model_name.element } #:nodoc: | |
- attr_accessor_with_default(:collection_name) { ActiveSupport::Inflector.pluralize(element_name) } #:nodoc: | |
+ attr_accessor :element_name | |
+ attr_accessor :collection_name | |
- attr_accessor_with_default(:primary_key, 'id') #:nodoc: | |
+ attr_accessor :primary_key | |
# Gets the \prefix for a resource's nested URL (e.g., <tt>prefix/collectionname/1.xml</tt>) | |
# This method is regenerated at runtime based on what the \prefix is set to. | |
@@ -1314,6 +1313,12 @@ module ActiveResource | |
super({ :root => self.class.element_name }.merge(options)) | |
end | |
+ def self.inherited(subclass) | |
+ subclass.element_name = subclass.model_name.element | |
+ subclass.collection_name = ActiveSupport::Inflector.pluralize(subclass.element_name) | |
+ subclass.primary_key = 'id' | |
+ end | |
+ | |
protected | |
def connection(refresh = false) | |
self.class.connection(refresh) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment