sinatra-rest-api 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b449f17fd838cc016b11e27e87b1d208fcccfa5
4
- data.tar.gz: 4b73597dc2f025d98bd0c0b63e677264cf7c4709
3
+ metadata.gz: f5318060016a3ab26172ab885d655e3a25d2b11b
4
+ data.tar.gz: '0648b121a0a9ee2cb83b7231569f937e16a0f19f'
5
5
  SHA512:
6
- metadata.gz: 3c11c07343c40019f11ff08cec601e02dc088ff6db0616dd369e71032bdcb13605cf9d10522ca320225c116e04d1ee5ca5dc929955bcc0898a8e8d37f785d091
7
- data.tar.gz: 826c896b9d4282ffd748d1c5d1c484f9e5b1865cf8b5a4d5bcf3488c99a44223039d1999b352d5c24bbabd2a8782ab363d9fb08d69220cbc97a3292dfb05d5b2
6
+ metadata.gz: a0909bde8929319bada54ed5a0c3ef42860be4177873cb183a1ed22895c455ade3d5c5ff14ad61bfe65b95be7262fdc229d26e32c1e88eaa3d63f1e1f72b3fe2
7
+ data.tar.gz: c3acb32b5312c06dc8ee91a85f9dae4779649fd317b719e88fb249a15be31480ee0ffe7961ce117f4665b0588543aebcae1974947732748d10f4c7c272138cea
@@ -51,7 +51,7 @@ module Sinatra
51
51
  # params[:_where] = '1=1' unless params[:_where].present?
52
52
  route_args[:response].headers['X-Total-Count'] = mapping[:count].call( params ).to_s
53
53
  result = mapping[:list].call( params, route_args[:fields] )
54
- [ 200, result.to_json( include: mapping[:relations].call( nil ) ) ]
54
+ [ 200, result.to_json( include: route_args[:options].include?( :include ) ? route_args[:options][:include] : mapping[:relations].call( nil ) ) ]
55
55
  end
56
56
 
57
57
  def self.other( _route_args, params, mapping )
@@ -61,9 +61,9 @@ module Sinatra
61
61
  [ 200, ret.nil? ? DONE.to_json : ret.to_json ]
62
62
  end
63
63
 
64
- def self.read( _route_args, params, mapping )
64
+ def self.read( route_args, params, mapping )
65
65
  result = mapping[:read].call( params )
66
- [ 200, result.to_json( include: mapping[:relations].call( nil ) ) ]
66
+ [ 200, result.to_json( include: route_args[:options].include?( :include ) ? route_args[:options][:include] : mapping[:relations].call( nil ) ) ]
67
67
  end
68
68
 
69
69
  def self.update( route_args, params, mapping )
@@ -2,7 +2,7 @@ module Sinatra
2
2
  module RestApi
3
3
  # Prodiver
4
4
  class Provider
5
- OPTIONS = [ :actions, :plural, :singular ].freeze
5
+ OPTIONS = [ :actions, :include, :plural, :singular ].freeze
6
6
  REQUEST = {
7
7
  # content_types: [ :formdata, :json, :multipart, :www_form ]
8
8
  content_types: [ :json, :www_form ]
@@ -33,10 +33,10 @@ module Sinatra
33
33
  path = "/#{@plural}#{data[:path]}"
34
34
  if data[:verb].is_a?( Array )
35
35
  data[:verb].each do |verb|
36
- prepare_route( route: route, resource: @path_singular, verb: verb, path: path, fields: data[:fields], mapping: @provider.adapter.mapping )
36
+ prepare_route( route: route, resource: @path_singular, verb: verb, path: path, fields: data[:fields], mapping: @provider.adapter.mapping, options: @provider.options )
37
37
  end
38
38
  else
39
- prepare_route( route: route, resource: @path_singular, verb: data[:verb], path: path, fields: data[:fields], mapping: @provider.adapter.mapping )
39
+ prepare_route( route: route, resource: @path_singular, verb: data[:verb], path: path, fields: data[:fields], mapping: @provider.adapter.mapping, options: @provider.options )
40
40
  end
41
41
  end
42
42
  @routes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-rest-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-30 00:00:00.000000000 Z
11
+ date: 2017-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra