jsend-rails 0.9.3 → 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,31 @@
1
1
  module JSend
2
2
  module Rails
3
3
  module Controller
4
+
5
+ # Render a jsend response
6
+ #
7
+ # By default, renders using +render json:+
8
+ #
9
+ # If you need to tweak rendering options, for example to render json inside
10
+ # a <textarea> to fix cranky browsers, pass a :render hash, like:
11
+ #
12
+ # +render_jsend {success: {}, render: {as: :text, layout: 'json'}}+
13
+ #
14
+ # In the :render, the :as key will be used to control the rendering format.
15
+ # Any other options will be passed directly to the render call. The example
16
+ # above will result in the following call to render:
17
+ #
18
+ # +render text: {...}, layout: 'json'+
4
19
  def render_jsend(options_or_status)
5
- render(:json => Envelope.compute(options_or_status))
20
+ render_options = if options_or_status.is_a?(Hash)
21
+ render_options = options_or_status[:render] || {}
22
+ format = render_options.delete(:as) || :json
23
+ render_options[format] = Envelope.compute(options_or_status).to_json
24
+ render_options
25
+ else
26
+ {json: Envelope.compute(options_or_status)}
27
+ end
28
+ render render_options
6
29
  end
7
30
  end
8
31
  end
@@ -1,5 +1,5 @@
1
1
  module JSend
2
2
  module Rails
3
- VERSION = "0.9.3"
3
+ VERSION = "0.9.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,50 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jsend-rails
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.4
4
5
  prerelease:
5
- version: 0.9.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Brian Moseley
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-12 00:00:00 -07:00
12
+ date: 2011-07-06 00:00:00.000000000 -04:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: rails
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &2164668180 !ruby/object:Gem::Requirement
20
18
  none: false
21
- requirements:
19
+ requirements:
22
20
  - - ~>
23
- - !ruby/object:Gem::Version
24
- version: "3.0"
21
+ - !ruby/object:Gem::Version
22
+ version: '3.0'
25
23
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
24
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *2164668180
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &2164667760 !ruby/object:Gem::Requirement
31
29
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
35
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
36
34
  type: :development
37
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: *2164667760
38
37
  description: Extensions to Rails 3 for rendering JSend responses
39
- email:
38
+ email:
40
39
  - bcm@copious.com
41
40
  executables: []
42
-
43
41
  extensions: []
44
-
45
42
  extra_rdoc_files: []
46
-
47
- files:
43
+ files:
48
44
  - lib/jsend-rails/controller.rb
49
45
  - lib/jsend-rails/envelope.rb
50
46
  - lib/jsend-rails/railtie.rb
@@ -56,30 +52,26 @@ files:
56
52
  has_rdoc: true
57
53
  homepage: http://github.com/utahstreetlabs/jsend-rails
58
54
  licenses: []
59
-
60
55
  post_install_message:
61
56
  rdoc_options: []
62
-
63
- require_paths:
57
+ require_paths:
64
58
  - lib
65
- required_ruby_version: !ruby/object:Gem::Requirement
59
+ required_ruby_version: !ruby/object:Gem::Requirement
66
60
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- version: "0"
71
- required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
66
  none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: "0"
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
77
71
  requirements: []
78
-
79
72
  rubyforge_project:
80
73
  rubygems_version: 1.6.2
81
74
  signing_key:
82
75
  specification_version: 3
83
76
  summary: Extends Rails 3 to render JSON responses in the JSend format
84
77
  test_files: []
85
-