activemodel-globalid 0.1.0 → 0.1.1

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: f7e637641e9bef7b9102466221a912f79e190f84
4
- data.tar.gz: b14880a4afca3cd86b76b9c5e52612d034558dd1
3
+ metadata.gz: 18f0e49373df39b515e35d8d504ee95c2ec9a99a
4
+ data.tar.gz: e3fe91038bfbad848fb286f7584a239ebbeb3370
5
5
  SHA512:
6
- metadata.gz: 0431d4062d488553aa64f953b7be68bea97e8c954ddba8082eebececd36f80e66091020473772d82880895e8466b3337266fdfcd53c987fe0f9143af52132493
7
- data.tar.gz: e25345afa813172b5a68251675d41e46077934062e4e7309bb4381ae2399fe2ddd0de5fbb21e56415a06e1b4013bd5a37f7e915d71c605d2436f4c0541aaa32b
6
+ metadata.gz: b883aade679f9f1bba26f2a1ba6b1630905a3f399a18133b015c8852f4cc5eb5752ef35391b398b353c82abe21af05d290da35a9c5d32e8d0c7717e0a3b64fa2
7
+ data.tar.gz: 5cde9bb37bf26cd8c80d6427abfe5e5daa6e19591f4b947255f14310c264a6e2557a0076f67b16204c9feb361d4ba21fef5f16a94042c74eafb1fe24aa5b68d0
@@ -16,7 +16,7 @@ module ActiveModel
16
16
  end
17
17
 
18
18
  def model_id
19
- @model_id ||= @gid.split("-").third
19
+ @model_id ||= @gid.split('-')[2..-1].join('-')
20
20
  end
21
21
 
22
22
  def ==(other_global_id)
@@ -6,13 +6,13 @@ module ActiveModel
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  def global_id
9
- GlobalID.create(self)
9
+ @global_id ||= GlobalID.create(self)
10
10
  end
11
11
  alias gid global_id
12
12
 
13
13
  def signed_global_id
14
- SignedGlobalID.create(self)
14
+ @signed_global_id ||= SignedGlobalID.create(self)
15
15
  end
16
16
  alias sgid signed_global_id
17
17
  end
18
- end
18
+ end
@@ -18,7 +18,7 @@ module ActiveModel
18
18
  if sgid.is_a? SignedGlobalID
19
19
  sgid.model_class.find(sgid.model_id)
20
20
  else
21
- locate SignedGlobalID.new(sgid)
21
+ locate_signed SignedGlobalID.new(sgid)
22
22
  end
23
23
  end
24
24
 
@@ -1,5 +1,19 @@
1
+ require 'rails/railtie'
1
2
  require 'active_model/global_identification'
3
+ require 'active_model/global_locator'
2
4
 
3
- ActiveModel::SignedGlobalID.verifier = Rails.application.message_verifier(:signed_global_ids)
5
+ module ActiveModel
6
+ # = Active Model GlobalID Railtie
7
+ class Railtie < Rails::Railtie # :nodoc:
8
+ initializer "active_model.globalid" do
9
+ config.after_initialize do |app|
10
+ ActiveModel::SignedGlobalID.verifier = app.message_verifier(:signed_global_ids)
11
+ end
12
+
13
+ ActiveSupport.on_load(:active_record) do
14
+ send :include, ActiveModel::GlobalIdentification
15
+ end
16
+ end
17
+ end
18
+ end
4
19
 
5
- ActiveRecord::Base.send :include, ActiveModel::GlobalIdentification
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemodel-globalid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-19 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 4.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 4.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activemodel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 4.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 4.1.0
41
41
  description: Serializing models to a single string makes it easy to pass references
@@ -61,17 +61,17 @@ require_paths:
61
61
  - lib
62
62
  required_ruby_version: !ruby/object:Gem::Requirement
63
63
  requirements:
64
- - - '>='
64
+ - - ">="
65
65
  - !ruby/object:Gem::Version
66
66
  version: 1.9.3
67
67
  required_rubygems_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
- - - '>='
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
71
  version: '0'
72
72
  requirements: []
73
73
  rubyforge_project:
74
- rubygems_version: 2.0.14
74
+ rubygems_version: 2.2.2
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: Serialize models that can be found by id again (will be part of Active Model).