transit-rails 0.8.2 → 0.8.3

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: 0b2ea19330744f7c8be409f68ad9dc63ac30c6be
4
- data.tar.gz: ebb7a7489ccbd206bd4274577221d1112bbc100a
3
+ metadata.gz: ace36664ed8c88e8c9529819446e2732c70b4f81
4
+ data.tar.gz: f8d1807e3f1a7d18bbf2d2c75d115ac814a938d0
5
5
  SHA512:
6
- metadata.gz: 09928faebfbb5d8c0e2bbe935953d7220512ccacbb7266bb1b6597a6f4c4954d614e7f3f7fef89ceb31a32829572100bf837f1c87130c9b5158d2bdb5d701ecf
7
- data.tar.gz: ba17b854278bdcc6cc0b856537c3f2d57979750d75c3a930f20bc5ec2027a029a1302573c8e7b4d4618efd3308a003c91502a49582048aa90e37ea196e44baac
6
+ metadata.gz: 80ef4691970d1de180e6e8a66f0bfa06939806b9090d5d40d1cb68920efd2e521fa63f82c9f1928bff5b4181975a38f50652174120e435558e7ffa2b7b3ff696
7
+ data.tar.gz: 575a453e336cb2a7e982d4852a8f979e7a77bb686b5707c6a87abd0fb5cfcbc9566b50d33b97729d4bd34692dc875deef80e3395e011a90fe1f71c9afab9aa14
@@ -3,7 +3,7 @@ require 'rails/railtie'
3
3
  module Transit
4
4
  module Rails
5
5
  class Railtie < ::Rails::Railtie
6
- config.after_initialize do
6
+ config.before_initialize do
7
7
  require 'transit/rails/renderer'
8
8
  require 'action_controller/metal/renderers'
9
9
 
@@ -11,10 +11,22 @@ module Transit
11
11
  Mime::Type.register_alias "application/transit+json", :transit_verbose
12
12
  Mime::Type.register "application/transit+msgpack", :transit_msgpack
13
13
 
14
+ end
15
+
16
+ config.after_initialize do
14
17
  ActionController.add_renderer :transit do |obj, options|
15
18
  Transit::Rails::Renderer.new(obj, options).render
16
19
  end
17
20
  end
21
+
22
+ initializer "transit.configure_rails_initialization" do |app|
23
+ require 'transit/rails/reader'
24
+ app.middleware.swap("ActionDispatch::ParamsParser",
25
+ "ActionDispatch::ParamsParser", {
26
+ Mime::TRANSIT => Transit::Rails::Reader.make_reader(:json),
27
+ Mime::TRANSIT_MSGPACK => Transit::Rails::Reader.make_reader(:msgpack)
28
+ })
29
+ end
18
30
  end
19
31
  end
20
32
  end
@@ -0,0 +1,14 @@
1
+ require 'transit'
2
+ require 'transit/reader'
3
+
4
+ module Transit
5
+ module Rails
6
+ class Reader
7
+ def self.make_reader(format)
8
+ lambda do |raw|
9
+ Transit::Reader.new(format, raw).read
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -35,8 +35,8 @@ module Transit
35
35
  private
36
36
  def serialize_for_transit(obj)
37
37
  return obj if String === obj
38
- if obj.respond_to?(:to_transit)
39
- obj.to_transit
38
+ if obj.respond_to?(:as_transit)
39
+ obj.as_transit
40
40
  elsif obj.respond_to?(:serializable_hash)
41
41
  if @symbolize_keys
42
42
  obj.serializable_hash.symbolize_keys
@@ -1,5 +1,5 @@
1
1
  module Transit
2
2
  module Rails
3
- VERSION = "0.8.2"
3
+ VERSION = "0.8.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: transit-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Davey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-07 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: transit-ruby
@@ -64,6 +64,7 @@ files:
64
64
  - lib/transit/rails.rb
65
65
  - lib/transit/rails/handlers.rb
66
66
  - lib/transit/rails/railtie.rb
67
+ - lib/transit/rails/reader.rb
67
68
  - lib/transit/rails/renderer.rb
68
69
  - lib/transit/rails/version.rb
69
70
  - spec/spec_helper.rb