beyond_the_api 0.0.2 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 409260205ded718cb885e863769982b17a7c34d5
4
- data.tar.gz: 21852f6583da61e6a0dc0ca46cdb79e29217805d
3
+ metadata.gz: 923e632d6a7bda509e55b4495898a49ccfe4e00f
4
+ data.tar.gz: f6f11947c64646eac64ab5baf11260f34a006cdf
5
5
  SHA512:
6
- metadata.gz: 2d257b40c0c2e31ab07bb64155d54865a4b2bdefd754fb2d2342afcb5f8fcd50842a4baec989826e49540c1667ec455d0a9a8e72ad17470bc95efcb6655a78b8
7
- data.tar.gz: be1f30b04c5bfb308cffe937f42e2a3069db6b1ba96fcc6ead6142d369eb782ddad656fbe7a24ee2724fac4578102fda32138305a09b40898e6a10977ce6210b
6
+ metadata.gz: d01207481508bf4353a2d9b835a962565de30123fa3fc1271b2f5d4f7df6246d73cd260f847a6d9fa4be04fc038b95ba363ac55ee40073cd5c24561fa8e7fd3d
7
+ data.tar.gz: a98856bc9f7f6fd0dbfab5e977795386d71624a447692bcdea0053cbf8663ad7c57310f49c9fa19d45ca6be35787951e2fc9f3a97722fb14dfba5a33981c69d1
data/changelog.md ADDED
@@ -0,0 +1,11 @@
1
+ ## 0.1
2
+
3
+ - Included fields and include params in index and show render_helpers
4
+
5
+ ## 0.0.2
6
+
7
+ - Active model serializers up to date (0.10.4) to be compatible with ruby 2.4.0
8
+
9
+ ## 0.0.1
10
+
11
+ - First release
data/config.reek CHANGED
@@ -8,29 +8,25 @@ UnusedPrivateMethod:
8
8
  NilCheck:
9
9
  enabled: false
10
10
 
11
- "app/controllers":
12
- TooManyStatements:
13
- max_statements: 10
14
- NestedIterators:
15
- max_allowed_nesting: 2
16
- UnusedPrivateMethod:
17
- enabled: false
18
- UncommunicativeModuleName:
19
- enabled: false
20
- InstanceVariableAssumption:
21
- enabled: false
22
- ManualDispatch:
23
- enabled: false
24
- "app/helpers":
11
+ "lib/beyond_the_api":
25
12
  UtilityFunction:
26
13
  enabled: false
27
14
  FeatureEnvy:
28
15
  enabled: false
29
16
  ManualDispatch:
30
17
  enabled: false
31
- "app/models":
32
- Attribute:
33
- enabled: false
18
+ TooManyStatements:
19
+ max_statements: 10
20
+ NestedIterators:
21
+ max_allowed_nesting: 2
22
+ UnusedPrivateMethod:
23
+ enabled: false
24
+ UncommunicativeModuleName:
25
+ enabled: false
26
+ InstanceVariableAssumption:
27
+ enabled: false
28
+ ManualDispatch:
29
+ enabled: false
34
30
  "app/serializer":
35
31
  RepeatedConditional:
36
32
  enabled: false
@@ -1,6 +1,7 @@
1
1
  require 'active_model_serializers'
2
2
  require 'will_paginate'
3
3
  require 'versionist'
4
+ require 'beyond_the_api/base'
4
5
  require 'beyond_the_api/render_helpers'
5
6
  require 'beyond_the_api/index_render_helpers'
6
7
  require 'beyond_the_api/show_render_helpers'
@@ -0,0 +1,9 @@
1
+ module BeyondTheApi
2
+ module Base
3
+ def add_fields_and_include_to_render_options(options)
4
+ options[:fields] = params[:fields]&.split(',')&.map(&:to_sym)
5
+ options[:include] = params[:include]&.split(',')&.map(&:to_sym)
6
+ options
7
+ end
8
+ end
9
+ end
@@ -20,7 +20,7 @@ module BeyondTheApi
20
20
  params_to_render = { json: @list, meta: @meta, current_user: current_user }
21
21
  serializer = options[:serializer]
22
22
  params_to_render[:each_serializer] = serializer if serializer
23
- params_to_render
23
+ add_fields_and_include_to_render_options(params_to_render)
24
24
  end
25
25
 
26
26
  def render_json_list_enum(list, name, options = {})
@@ -3,6 +3,7 @@ module BeyondTheApi
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
+ include ::BeyondTheApi::Base
6
7
  include ::BeyondTheApi::IndexRenderHelpers
7
8
  include ::BeyondTheApi::ShowRenderHelpers
8
9
  before_action :set_meta
@@ -3,6 +3,7 @@ module BeyondTheApi
3
3
  def render_json_serializer(object, options = {})
4
4
  render_params = { json: object, current_user: current_user, meta: @meta,
5
5
  status: (options[:status] || :ok) }
6
+ add_fields_and_include_to_render_options(render_params)
6
7
 
7
8
  render render_params.merge(render_json_serializer_aditional_params(options))
8
9
  end
@@ -1,3 +1,3 @@
1
1
  module BeyondTheApi
2
- VERSION = '0.0.2'
2
+ VERSION = '0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond_the_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: '0.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Weckl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-06 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -113,8 +113,10 @@ files:
113
113
  - LICENSE.txt
114
114
  - README.md
115
115
  - beyond_the_api.gemspec
116
+ - changelog.md
116
117
  - config.reek
117
118
  - lib/beyond_the_api.rb
119
+ - lib/beyond_the_api/base.rb
118
120
  - lib/beyond_the_api/index_render_helpers.rb
119
121
  - lib/beyond_the_api/render_helpers.rb
120
122
  - lib/beyond_the_api/show_render_helpers.rb