Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
259c9ceb
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
259c9ceb
编写于
1月 22, 2012
作者:
J
Jeremy Kemper
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Prefer to document with https:// example URLs and no port numbers
上级
60615a46
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
20 deletion
+20
-20
activeresource/lib/active_resource/base.rb
activeresource/lib/active_resource/base.rb
+18
-18
activeresource/lib/active_resource/custom_methods.rb
activeresource/lib/active_resource/custom_methods.rb
+1
-1
activeresource/test/fixtures/street_address.rb
activeresource/test/fixtures/street_address.rb
+1
-1
未找到文件。
activeresource/lib/active_resource/base.rb
浏览文件 @
259c9ceb
...
...
@@ -31,23 +31,23 @@ module ActiveResource
# URI of the resources.
#
# class Person < ActiveResource::Base
# self.site = "http
://api.people.com:3000/
"
# self.site = "http
s://api.people.com
"
# end
#
# Now the Person class is mapped to RESTful resources located at <tt>http
://api.people.com:3000
/people/</tt>, and
# Now the Person class is mapped to RESTful resources located at <tt>http
s://api.people.com
/people/</tt>, and
# you can now use Active Resource's life cycle methods to manipulate resources. In the case where you already have
# an existing model with the same name as the desired RESTful resource you can set the +element_name+ value.
#
# class PersonResource < ActiveResource::Base
# self.site = "http
://api.people.com:3000/
"
# self.site = "http
s://api.people.com
"
# self.element_name = "person"
# end
#
# If your Active Resource object is required to use an HTTP proxy you can set the +proxy+ value which holds a URI.
#
# class PersonResource < ActiveResource::Base
# self.site = "http
://api.people.com:3000/
"
# self.proxy = "http://user:password@proxy.people.com:8080"
# self.site = "http
s://api.people.com
"
# self.proxy = "http
s
://user:password@proxy.people.com:8080"
# end
#
#
...
...
@@ -103,7 +103,7 @@ module ActiveResource
# You can validate resources client side by overriding validation methods in the base class.
#
# class Person < ActiveResource::Base
# self.site = "http
://api.people.com:3000/
"
# self.site = "http
s://api.people.com
"
# protected
# def validate
# errors.add("last", "has invalid characters") unless last =~ /[a-zA-Z]*/
...
...
@@ -176,7 +176,7 @@ module ActiveResource
# response code will be returned from the server which will raise an ActiveResource::ResourceNotFound
# exception.
#
# # GET http
://api.people.com:3000
/people/999.json
# # GET http
s://api.people.com
/people/999.json
# ryan = Person.find(999) # 404, raises ActiveResource::ResourceNotFound
#
#
...
...
@@ -212,7 +212,7 @@ module ActiveResource
# an ActiveResource::MissingPrefixParam will be raised.
#
# class Comment < ActiveResource::Base
# self.site = "http
://someip.com/posts/:post_id/
"
# self.site = "http
s://someip.com/posts/:post_id
"
# end
#
# Comment.find(1)
...
...
@@ -230,9 +230,9 @@ module ActiveResource
# ryan.save # => false
#
# # When
# # PUT http
://api.people.com:3000
/people/1.json
# # PUT http
s://api.people.com
/people/1.json
# # or
# # PUT http
://api.people.com:3000
/people/1.json
# # PUT http
s://api.people.com
/people/1.json
# # is requested with invalid values, the response is:
# #
# # Response (422):
...
...
@@ -253,7 +253,7 @@ module ActiveResource
# amount of time before Active Resource times out with the +timeout+ variable.
#
# class Person < ActiveResource::Base
# self.site = "http
://api.people.com:3000/
"
# self.site = "http
s://api.people.com
"
# self.timeout = 5
# end
#
...
...
@@ -403,15 +403,15 @@ def site
#
# With superclass_delegating_reader
#
# Parent.site = 'http://anonymous@test.com'
# Subclass.site # => 'http://anonymous@test.com'
# Parent.site = 'http
s
://anonymous@test.com'
# Subclass.site # => 'http
s
://anonymous@test.com'
# Subclass.site.user = 'david'
# Parent.site # => 'http://david@test.com'
# Parent.site # => 'http
s
://david@test.com'
#
# Without superclass_delegating_reader (expected behavior)
#
# Parent.site = 'http://anonymous@test.com'
# Subclass.site # => 'http://anonymous@test.com'
# Parent.site = 'http
s
://anonymous@test.com'
# Subclass.site # => 'http
s
://anonymous@test.com'
# Subclass.site.user = 'david' # => TypeError: can't modify frozen object
#
if
defined?
(
@site
)
...
...
@@ -651,7 +651,7 @@ def prefix(options={}) "#{prefix_call}" end
# # => /posts/1.json
#
# class Comment < ActiveResource::Base
# self.site = "http
://37s.sunrise.i/posts/:post_id/
"
# self.site = "http
s://37s.sunrise.com/posts/:post_id
"
# end
#
# Comment.element_path(1, :post_id => 5)
...
...
@@ -681,7 +681,7 @@ def element_path(id, prefix_options = {}, query_options = nil)
# # => /posts/new.json
#
# class Comment < ActiveResource::Base
# self.site = "http
://37s.sunrise.i/posts/:post_id/
"
# self.site = "http
s://37s.sunrise.com/posts/:post_id
"
# end
#
# Comment.collection_path(:post_id => 5)
...
...
activeresource/lib/active_resource/custom_methods.rb
浏览文件 @
259c9ceb
...
...
@@ -20,7 +20,7 @@ module ActiveResource
# standard methods.
#
# class Person < ActiveResource::Base
# self.site = "http
://37s.sunrise.i:3000
"
# self.site = "http
s://37s.sunrise.com
"
# end
#
# Person.new(:name => 'Ryan').post(:register) # POST /people/new/register.json
...
...
activeresource/test/fixtures/street_address.rb
浏览文件 @
259c9ceb
class
StreetAddress
<
ActiveResource
::
Base
self
.
site
=
"http://37s.sunrise.i:3000/people/:person_id
/
"
self
.
site
=
"http://37s.sunrise.i:3000/people/:person_id"
self
.
element_name
=
'address'
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录