Skip to content

Commit

Permalink
Remove url options
Browse files Browse the repository at this point in the history
Removing url options because It does not works at all.
Thus, there are others PR at the moment to include url(links) as well.
  • Loading branch information
bacarini authored and NullVoxPopuli committed Sep 7, 2015
1 parent 9d2bca0 commit 02766ab
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 55 deletions.
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.

0 comments on commit 02766ab

Please sign in to comment.