out_put 2.3.0 → 2.3.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
- SHA1:
3
- metadata.gz: 8b5565a2cfe9fabb5a97d40b9bc7c2f512fcad54
4
- data.tar.gz: f57098b58b8d4ba72d8c7536bfd89e9712b670bb
2
+ SHA256:
3
+ metadata.gz: 6263458e404b6c61cabd1e5474ccbbc2eb5546fed9c4e41b87467cf4d8859b46
4
+ data.tar.gz: 661005b6445528f58106a0485b9479f94b86575a0190504ac485c16a5a845eb2
5
5
  SHA512:
6
- metadata.gz: 79c6083a2d017dc7831c4d07e5bf2dec795e7143e4041f49684d5652eab88f8024d8d5ca90ddd7e31e0bf9938b1393da7d6d80eaa991facb6f63494eb2bcae24
7
- data.tar.gz: d56be4ee9103076c9c7850c227611b3f64862576e40fc287d20d42bad8134f6e26cd6d80d816f837580f8433ae9d7cb1cd79d73767d68d44d798c06539aefcb5
6
+ metadata.gz: 1f4d8c0d385525cff1d423edee752d92c6412361c1bcffc28bb34b1730c2b470bd52a512c5ca0586d005c7940182efc9a5f23134775f61f8e1821637a2a90604
7
+ data.tar.gz: 909430d54859890ca183be0fb2262d481afe974c2f58dac58ea50ae8993762bd056f5b817ae462848272df616296ec4517ca969212d391d5bd107e77fd71eda1
@@ -5,7 +5,8 @@ require 'out_put/config'
5
5
  require 'out_put/view'
6
6
 
7
7
  module OutPut
8
- def output(code = 0, msg = '', only: nil, http: 200, cache: nil, **data, &block)
8
+ def output(code = 0, msg = '', only: nil, http: 200, cache: nil, data: nil, **d, &block)
9
+ data ||= d || { }
9
10
  if !code.is_a?(Integer) && code.respond_to?(:info)
10
11
  only = code.info[:only]
11
12
  code, msg, http, data = code.info.values_at(:code, :msg, :http, :data)
@@ -13,8 +14,8 @@ module OutPut
13
14
  data, only = _output_cache(cache, data: data, only: only, &block)
14
15
  end
15
16
 
16
- return rendrer json: only.except(:http), status: only[:http] || http if only.present?
17
- render json: { result: _output_result(code, msg), data: _output_data(data) }, status: http
17
+ return render json: only.except(:http), status: only[:http] || http if only.present?
18
+ render json: { result: _output_result(code, msg), data: data }, status: http
18
19
  end
19
20
 
20
21
  alias ok output
@@ -36,15 +37,6 @@ module OutPut
36
37
  { code: code, message: msg }
37
38
  end
38
39
 
39
- def _output_data(data)
40
- if data&.key?(Config.pagination_for)
41
- # TODO now is only for AR
42
- data.merge!(total: data[Config.pagination_for].try(:unscoped).count)
43
- end
44
-
45
- data || { }
46
- end
47
-
48
40
  def _output_cache(time, data: { }, only: nil, &block)
49
41
  cached = Rails.cache.fetch("output/#{action_name}", expires_in: time) do
50
42
  instance_eval(&block)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OutPut
4
- VERSION = '2.3.0'
4
+ VERSION = '2.3.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: out_put
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhandao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-03 00:00:00.000000000 Z
11
+ date: 2019-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  requirements: []
96
96
  rubyforge_project:
97
- rubygems_version: 2.6.12
97
+ rubygems_version: 2.7.3
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: Render JSON response in a unified format