提交 1d31a043 编写于 作者: M Marcel Molina

Use attr_accessor_with_default to dry up attribute initialization. References...

Use attr_accessor_with_default to dry up attribute initialization. References #6538. [Stuart Halloway]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5540 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 309a6bd5
*SVN*
* Use attr_accessor_with_default to dry up attribute initialization. References #6538. [Stuart Halloway]
* Add basic logging support for logging outgoing requests. [Jamis Buck]
* Add Base.delete for deleting resources without having to instantiate them first. [Jamis Buck]
......
......@@ -20,14 +20,10 @@ def connection(refresh = false)
@connection
end
def element_name
self.to_s.underscore
end
def collection_name
element_name.pluralize
end
attr_accessor_with_default(:element_name) { to_s.underscore }
attr_accessor_with_default(:collection_name) { element_name.pluralize }
attr_accessor_with_default(:primary_key, 'id')
def prefix(options={})
default = site.path
default << '/' unless default[-1..-1] == '/'
......@@ -42,16 +38,7 @@ def prefix=(value = '/')
end
alias_method :set_prefix, :prefix=
def element_name=(value)
class << self ; attr_reader :element_name ; end
@element_name = value
end
alias_method :set_element_name, :element_name=
def collection_name=(value)
class << self ; attr_reader :collection_name ; end
@collection_name = value
end
alias_method :set_collection_name, :collection_name=
def element_path(id, options = {})
......@@ -62,14 +49,6 @@ def collection_path(options = {})
"#{prefix(options)}#{collection_name}.xml"
end
def primary_key
self.primary_key = 'id'
end
def primary_key=(value)
class << self ; attr_reader :primary_key ; end
@primary_key = value
end
alias_method :set_primary_key, :primary_key=
# Person.find(1) # => GET /people/1.xml
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册