Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove url options #1123

Merged
merged 1 commit into from
Sep 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class PostSerializer < ActiveModel::Serializer
attributes :title, :body

has_many :comments

url :post
end
```

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

belongs_to :post

url [:post, :comment]
end
```

Expand Down Expand Up @@ -239,8 +235,6 @@ class PostSerializer < ActiveModel::Serializer

has_many :comments
has_one :author

url :post
end
```

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

belongs_to :post_id

url [:post, :comment]
end
```

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

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

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.
Expand Down Expand Up @@ -307,8 +297,6 @@ class PostSerializer < ActiveModel::Serializer
attributes :title, :body

has_many :comments

url :post
end
```

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

has_many :comments

url :post
end
```

Expand Down
10 changes: 0 additions & 10 deletions lib/active_model/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Serializer
class << self
attr_accessor :_attributes
attr_accessor :_attributes_keys
attr_accessor :_urls
attr_accessor :_cache
attr_accessor :_fragmented
attr_accessor :_cache_key
Expand All @@ -44,7 +43,6 @@ class << self
def self.inherited(base)
base._attributes = self._attributes.try(:dup) || []
base._attributes_keys = self._attributes_keys.try(:dup) || {}
base._urls = []
base._cache_digest = digest_caller_file(caller.first)
super
end
Expand Down Expand Up @@ -86,14 +84,6 @@ def self.cache(options = {})
@_cache_options = (options.empty?) ? nil : options
end

def self.url(attr)
@_urls.push attr
end

def self.urls(*attrs)
@_urls.concat attrs
end

def self.serializer_for(resource, options = {})
if resource.respond_to?(:serializer_class)
resource.serializer_class
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class PostSerializer < ActiveModel::Serializer

has_many :comments
belongs_to :author
url :comments
end

class CommentSerializer < ActiveModel::Serializer
Expand Down
5 changes: 0 additions & 5 deletions test/fixtures/poro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,13 @@ class Profile < Model
class ProfileSerializer < ActiveModel::Serializer
attributes :name, :description

urls :posts, :comments

def arguments_passed_in?
options[:my_options] == :accessible
end
end

class ProfilePreviewSerializer < ActiveModel::Serializer
attributes :name

urls :posts, :comments
end

Post = Class.new(Model)
Expand Down Expand Up @@ -100,7 +96,6 @@ module Spam; end
has_many :comments
belongs_to :blog
belongs_to :author
url :comments

def blog
Blog.new(id: 999, name: 'Custom blog')
Expand Down
25 changes: 0 additions & 25 deletions test/serializers/urls_test.rb

This file was deleted.