Commit Graph

112 Commits

Author SHA1 Message Date
Benjamin Fleischer
b50195fde7 Add a deprecation DSL 2016-03-07 01:07:06 -06:00
Yohan Robert
dd94fe2163 Follow up to #1535
- The removed classes and modules were added back with deprecation
  warning and deprecation test were added for them.
- One test was renamed because it contained `__`.
- Some tests were refactored.
- The ActiveModelSerializers::Deserialization module is now called
  Adapter instead of ActiveModelSerializers::Adapter.
- The changelog was added for #1535
2016-03-06 23:15:39 -06:00
bobba surendranath chowdary
252f9c4ae9 Moved the adapter and adapter folder to active_model_serializers folder and changed the module namespace
Changed the namespace in adapters and folder to active_model_serializers from active_model::serializer

Changed namespace of adapters in serializers and other folders

Moved adapter_for_test file to active_model_serializers folder and changed namespace of adapter inside the test file

Require ActiveSupport's string/inflections

We depend on string/inflections to define String#underscore.

Refactor JsonApi adapter to avoid redundant computations.

Update readme.md to link to v0.10.0.rc4

changed namespace of adapter folder testcases

Changed all namespaces of adapter under active_moder_serializers

Namespaced IncludeTree which is from serializer module, so needed to namespace it properly

Fixed wrong namsepacing of fieldset

namespace change in deserializer json_api

Fixed the namespace for collection serializer when used inside adapter, changed namespace for adapter to new namespace which I had forgotten previously

Modified logging test and adapter test cases to make the testcases pass

Changed the yardoc links,as old links are not taking to documentation pages,proper links for 0.10,0.9 and 0.8 in rubydoc

Rubocop errors are fixed by underscore naming unused variables

Moved the require of adapter to serializable resource

Remoeved adapter dependency inside serializer and added warning to Serializer::adapter method

Fixed frament cache test which is calling Serializer.adapter

Changed the name of lookup_adapter_from_config to configured_adapter

Changed the docs which will show the new namespace of adapters

Rubocop fix
2016-02-23 21:49:58 -06:00
Lucas Hosseini
30d8414cce Add support for dynamic string-links in JsonApi adapter. 2016-01-15 14:36:42 +01:00
Benjamin Fleischer
87ca408ead Merge pull request #1425 from beauby/extract-serializer-modules
[CLEANUP] Extract links and type-related methods to their own module.
2016-01-15 00:56:40 -06:00
Lucas Hosseini
20a58d7f5c Add support for JSON API deserialization (experimental). 2016-01-13 05:48:06 +01:00
Lucas Hosseini
f6fe0c8aa3 Extract links and type-related methods to their own module. 2016-01-12 15:05:39 +01:00
Benjamin Fleischer
ce17a1b305 [DOCS] Refactor, update, create documentation [ci skip] 2015-12-14 14:38:29 -06:00
tchak
31172b1be5 rename context to serialization_context 2015-11-07 20:32:27 +01:00
Lucas Hosseini
8ac2b9b01f Minor cleanup. 2015-11-03 23:59:12 +01:00
Lucas Hosseini
3804dcc238 Add support for resource-level JSON API links. 2015-11-03 23:50:16 +01:00
Lucas Hosseini
0948c4199a Compute only requested attributes. 2015-10-31 19:20:53 +01:00
L. Preston Sego III
17be650538 Revert "rename context to serialization_context and add url helpers" 2015-10-29 08:16:47 -04:00
L. Preston Sego III
a063cbea21 Merge pull request #1289 from tchak/serialization_context
rename context to serialization_context and add url helpers
2015-10-29 07:56:47 -04:00
Lucas Hosseini
b5aecfd114 Initialize fieldset. 2015-10-25 19:56:43 +01:00
Lucas Hosseini
13ef8fed1b Fix fields option to restrict relationships as well. 2015-10-24 21:28:13 +02:00
tchak
d08ee5994f rename context to serialization_context and add url helpers 2015-10-22 22:28:54 +02:00
João Moura
da7e6dc795 Merge pull request #1247 from beauby/jsonapi-toplevel-links
Add support for toplevel JSON API links.
2015-10-10 17:52:08 -03:00
Benjamin Fleischer
49eb531539 Merge pull request #1239 from beauby/fix-duplicate-jsonapi
Fix duplicate resources inside included in compound document.
2015-10-08 14:19:02 -05:00
Benjamin Fleischer
dc44b136aa Remove unnecessarily silenced warnings 2015-10-07 05:54:57 -05:00
Lucas Hosseini
54303b6290 Add support for toplevel JSON API links. 2015-10-06 20:01:46 +02:00
Lucas Hosseini
f4bb4c81b0 Fix duplicate resources between data and included. 2015-10-06 17:25:27 +02:00
Lucas Hosseini
658810e6a0 Extract attributes filtering from serializer into adapter. 2015-10-05 08:21:26 +02:00
Benjamin Fleischer
a2bfe190e3 Merge pull request #1050 from bf4/json_api_member
Add top-level jsonapi member to JSON API adapter
2015-10-01 23:03:11 -05:00
Ivan Yurov
2dd569ae51 Add Serializer 'type' directive to control type field, for use by the JsonApi adapter 2015-10-01 22:48:57 -04:00
Benjamin Fleischer
9d7da8afc4 Add support for top level jsonapi member. 2015-10-01 21:22:49 -05:00
Lucas Hosseini
ac06013aeb Add support for wildcard includes + improve perfs on JsonApi includes. 2015-09-21 05:58:00 +02:00
Benjamin Fleischer
19de5f7722 Introduce Adapter::Base
Breaking change:
- Adapters now inherit Adapter::Base
- 'Adapter' is now a module, no longer a class
Why?

- using a class as a namespace that you also inherit from is complicated and circular at time i.e.
  buggy (see https://github.com/rails-api/active_model_serializers/pull/1177)
- The class methods on Adapter aren't necessarily related to the instance methods, they're more
    Adapter functions
- named `Base` because it's a Rails-ism
- It helps to isolate and highlight what the Adapter interface actually is
2015-09-20 12:26:04 -05:00
Benjamin Fleischer
ad2ca3b45c Remove Adapter autoloads in favor of require
Adapters must be eager loaded to ensure they are defined
before they are used as namespacing.

cf6a074a1c (diff-41f2b3509d33e1c65bb70ee0ec7a2eea)
2015-09-18 12:44:53 -05:00
Benjamin Fleischer
9d65f0adc5 Distinguish options ivar from local; Extract latent Adapter::CachedSerializer 2015-09-17 10:45:09 -05:00
João Moura
479146c02a Merge pull request #1121 from beauby/fix-jsonapi-links
Refactor `add_links` in JSONAPI adapter.
2015-09-15 05:00:39 -03:00
Lucas Hosseini
fb7ec88e2e Remove unnecessary parentheses accidentally reintroduced in #1017. 2015-09-15 00:25:37 +02:00
Lucas Hosseini
319a9071af Remove legacy method accidentally reintroduced in #1017. 2015-09-15 00:22:28 +02:00
Lucas Hosseini
285cdf841e Split serializable_hash into two methods. 2015-09-14 06:46:52 +02:00
Lucas Hosseini
572ff7db20 Refactor add_links in JSONAPI adapter. 2015-09-14 06:46:52 +02:00
Lucas Hosseini
ce7a839f3d Extended format for JSONAPI include option. 2015-09-13 22:45:47 +02:00
Benjamin Fleischer
af99c0d9e6 Ensure inheritance hooks run
I was seeing transient failures where adapters may not be registered.

e.g. https://travis-ci.org/rails-api/active_model_serializers/builds/77735382

Since we're using the Adapter, JsonApi, and Json classes
as namespaces, some of the conventions we use for modules don't apply.
Basically, we don't want to define the class anywhere besides itself.
Otherwise, the inherited hooks may not run, and some adapters may not
be registered.

For example:

If we have a class Api `class Api; end`
And Api is also used as a namespace for `Api::Product`
And the classes are defined in different files.

In one file:

```ruby
class Api
  autoload :Product
  def self.inherited(subclass)
    puts
    p [:inherited, subclass.name]
    puts
  end
end
```

And in another:

```ruby
class Api
  class Product < Api
    def sell_sell_sell!
      # TODO: sell
    end
  end
end
```

If we load the Api class file first, the inherited hook will be defined on the class
so that when we load the Api::Product class, we'll see the output:

```plain
[ :inherited, Api::Product]
```

However, if we load the Api::Product class first, since it defines the `Api` class
and then inherited from it, the Api file was never loaded, the hook never defined,
and thus never run.

By defining the class as `class Api::Product < Api` We ensure the the Api class
MUST be defined, and thus, the hook will be defined and run and so sunshine and unicorns.

Appendix:

The below would work, but triggers a circular reference warning.
It's also not recommended to mix require with autoload.

```ruby
require 'api'
class Api
  class Product < Api
    def sell_sell_sell!
      # TODO: sell
    end
  end
end
```

This failure scenario was introduced by removing the circular reference warnings in
https://github.com/rails-api/active_model_serializers/pull/1067

Style note:

To make diffs on the adapters smalleer and easier to read, I've maintained the same
identention that was in the original file.  I've decided to prefer ease of reading
the diff over style, esp. since we may later return to the preferred class declaration style.

 with '#' will be ignored, and an empty message aborts the commit.
2015-09-09 08:55:20 -05:00
Lucas Hosseini
f27f13ccc1 Fix style. 2015-09-06 19:29:51 +02:00
Lucas Hosseini
070a2e63bd Merge remote-tracking branch 'upstream/master' into fix-jsonapi-ri 2015-09-06 17:21:43 +02:00
Benjamin Fleischer
228cc1c92a Rubocop: Consistent spacing 2015-09-03 20:51:40 -05:00
Lucas Hosseini
3793f3ff4b Rename resource_objects_for to primary_data_for. 2015-09-02 19:27:40 +02:00
Lucas Hosseini
f8c553a0ed Cleanup. 2015-09-02 15:58:31 +02:00
Lucas Hosseini
a8a0566d29 Refactor relationships_for. 2015-09-01 21:16:00 +02:00
Lucas Hosseini
c593adbcb2 Further cleanup add_included. 2015-09-01 20:46:18 +02:00
Lucas Hosseini
bae4951e05 Further cleanup included_for. 2015-09-01 20:30:38 +02:00
Lucas Hosseini
91c5cbe0b9 Cleanup add_included. 2015-09-01 17:57:30 +02:00
Lucas Hosseini
f7612f2542 Further refactor/streamline method names. 2015-09-01 16:52:43 +02:00
Lucas Hosseini
04012052a6 Fix 'id' -> :id. 2015-09-01 15:39:29 +02:00
Lucas Hosseini
c4faafdebc Refactor resource_identifier. 2015-09-01 10:15:50 +02:00
Lucas Hosseini
d9c680599a Refactor. 2015-09-01 01:41:29 +02:00