Skip to content

Commit 8634503

Browse files
committed
Remove url options
Removing url options because It does not works at all. Thus, there are others PR at the moment to include url(links) as well.
1 parent f149e50 commit 8634503

File tree

5 files changed

+0
-55
lines changed

5 files changed

+0
-55
lines changed

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ class PostSerializer < ActiveModel::Serializer
3636
attributes :title, :body
3737

3838
has_many :comments
39-
40-
url :post
4139
end
4240
```
4341

@@ -48,8 +46,6 @@ class CommentSerializer < ActiveModel::Serializer
4846
attributes :name, :body
4947

5048
belongs_to :post
51-
52-
url [:post, :comment]
5349
end
5450
```
5551

@@ -239,8 +235,6 @@ class PostSerializer < ActiveModel::Serializer
239235

240236
has_many :comments
241237
has_one :author
242-
243-
url :post
244238
end
245239
```
246240

@@ -251,8 +245,6 @@ class CommentSerializer < ActiveModel::Serializer
251245
attributes :name, :body
252246

253247
belongs_to :post_id
254-
255-
url [:post, :comment]
256248
end
257249
```
258250

@@ -274,8 +266,6 @@ And you can change the JSON key that the serializer should use for a particular
274266
has_many :comments, key: :reviews
275267
```
276268

277-
The `url` declaration describes which named routes to use while generating URLs
278-
for your JSON. Not every adapter will require URLs.
279269
## Pagination
280270

281271
Pagination links will be included in your response automatically as long as the resource is paginated using [Kaminari](https://github.com/amatsuda/kaminari) or [WillPaginate](https://github.com/mislav/will_paginate) and if you are using a ```JSON-API``` adapter.
@@ -307,8 +297,6 @@ class PostSerializer < ActiveModel::Serializer
307297
attributes :title, :body
308298

309299
has_many :comments
310-
311-
url :post
312300
end
313301
```
314302

@@ -332,8 +320,6 @@ class PostSerializer < ActiveModel::Serializer
332320
attributes :title, :body
333321

334322
has_many :comments
335-
336-
url :post
337323
end
338324
```
339325

lib/active_model/serializer.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class Serializer
3131
class << self
3232
attr_accessor :_attributes
3333
attr_accessor :_attributes_keys
34-
attr_accessor :_urls
3534
attr_accessor :_cache
3635
attr_accessor :_fragmented
3736
attr_accessor :_cache_key
@@ -44,7 +43,6 @@ class << self
4443
def self.inherited(base)
4544
base._attributes = self._attributes.try(:dup) || []
4645
base._attributes_keys = self._attributes_keys.try(:dup) || {}
47-
base._urls = []
4846
base._cache_digest = digest_caller_file(caller.first)
4947
super
5048
end
@@ -86,14 +84,6 @@ def self.cache(options = {})
8684
@_cache_options = (options.empty?) ? nil : options
8785
end
8886

89-
def self.url(attr)
90-
@_urls.push attr
91-
end
92-
93-
def self.urls(*attrs)
94-
@_urls.concat attrs
95-
end
96-
9787
def self.serializer_for(resource, options = {})
9888
if resource.respond_to?(:serializer_class)
9989
resource.serializer_class

test/fixtures/active_record.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class PostSerializer < ActiveModel::Serializer
4040

4141
has_many :comments
4242
belongs_to :author
43-
url :comments
4443
end
4544

4645
class CommentSerializer < ActiveModel::Serializer

test/fixtures/poro.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,13 @@ class Profile < Model
5959
class ProfileSerializer < ActiveModel::Serializer
6060
attributes :name, :description
6161

62-
urls :posts, :comments
63-
6462
def arguments_passed_in?
6563
options[:my_options] == :accessible
6664
end
6765
end
6866

6967
class ProfilePreviewSerializer < ActiveModel::Serializer
7068
attributes :name
71-
72-
urls :posts, :comments
7369
end
7470

7571
Post = Class.new(Model)
@@ -100,7 +96,6 @@ module Spam; end
10096
has_many :comments
10197
belongs_to :blog
10298
belongs_to :author
103-
url :comments
10499

105100
def blog
106101
Blog.new(id: 999, name: 'Custom blog')

test/serializers/urls_test.rb

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)