activerecord-propertybase_id 0.2.0 → 0.3.0

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: 6b2198cfd17a6377ce1959968ebf3a3aac67b1cc
4
- data.tar.gz: 59bb49f34e49c28efce1f059c823604441b9d521
3
+ metadata.gz: 26f5a4e1850a56a83d8c6000780eaa95f7fb63cc
4
+ data.tar.gz: f1528ea64f6392619ada3b46ea1bb6c1e714902e
5
5
  SHA512:
6
- metadata.gz: 9a0171a81ed4e44f36515ba7427d505943bfdee3dfb7be8b71a46bb0ceddf1c4d0d549fb41160c2ad5dcb7dbf2051476dc859603e1e72e116f61044a9d35b88f
7
- data.tar.gz: b31e21c40ce98917e618e035b53835f4d2c16cd8bdb240763f29e0737bc09284e9d1b7a0fd0eb1943022279f7de2be6350e00e13bcebc5bbae6c2d28f2373a5c
6
+ metadata.gz: 98b5137743e268d3fe435913aac6bf25f25f1df08b6507d94c003fb50b17bdd221c8d35847098783176162be352f4b5daeb223e6cd61956595cc5aa5dfcea774
7
+ data.tar.gz: 08e5d12ffcf030d7e15a4802fa3b6e32cc25a73ae129cee31c1caa4ebd70b434762b95006fac468ce5342f0016bb4e43fd86c09ec0e9298d28489c5c6a2b0e44
data/.gitignore CHANGED
@@ -8,3 +8,4 @@
8
8
  /spec/reports/
9
9
  /spec/debug.log
10
10
  /tmp/
11
+ /vendor/bundle
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
4
  - 2.1.5
5
- - 2.2.1
5
+ - 2.2.2
6
6
  - rbx
7
7
  - ruby-head
8
8
  - jruby-head
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # ActiveRecord::PropertybaseId
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/activerecord/propertybase_id`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This Gem lets you easily integrate [propertybase_id](github.com/propertybase/propertybase_id) into your ActiveRecord model.
6
4
 
7
5
  ## Installation
8
6
 
@@ -26,7 +24,7 @@ This ActiveRecord extension lets you use the [Propertybase ID](https://github.co
26
24
 
27
25
  ### Migration
28
26
 
29
- The Propertybase ID is stored via the `char(8)` data type (currently only tested on SQLite and PostgreSQL). You can also use the cusom migration type `propertybase_id`.
27
+ The Propertybase ID is stored via the `char(18)` data type (currently only tested on SQLite and PostgreSQL). You can also use the cusom migration type `propertybase_id`.
30
28
 
31
29
  Note: As Rails doesn't really support changing the type of the primary key in the migration. You need to work around a little bit. You need to disable the ID for a sepcific table and then add it as
32
30
 
@@ -75,7 +73,7 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
75
73
 
76
74
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
77
75
 
78
- ## Atribution
76
+ ## Attribution
79
77
 
80
78
  Heavily inspired by [activeuuid](https://github.com/jashmenn/activeuuid).
81
79
 
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "propertybase_id", ">= 0.3.3"
21
+ spec.add_dependency "propertybase_id", ">= 0.4.0"
22
22
  spec.add_dependency "activerecord", ">= 4.2", "< 4.3"
23
23
 
24
24
  spec.add_development_dependency "bundler", "< 1.10"
@@ -18,7 +18,7 @@ module ActiveRecord
18
18
 
19
19
  included do
20
20
  def add_column_with_propertybase_id(name, type, options)
21
- type = PB_ID_SQL_TYPE if type.to_sym == :propertybase_id
21
+ type = PB_ID_SQL_TYPE if type.to_s == "propertybase_id"
22
22
  add_column_without_propertybase_id(name, type, options)
23
23
  end
24
24
 
@@ -26,10 +26,42 @@ module ActiveRecord
26
26
  end
27
27
  end
28
28
 
29
+ module AddReferencePropertybaseIdColumn
30
+ extend ActiveSupport::Concern
31
+
32
+ included do
33
+ def add_reference_with_propertybase_id(table_name, ref_name, options = {})
34
+ options.merge!(type: PB_ID_SQL_TYPE) if options[:type].to_s == "propertybase_id"
35
+ add_reference_without_propertybase_id(table_name, ref_name, options)
36
+ end
37
+
38
+ alias_method_chain :add_reference, :propertybase_id
39
+ end
40
+ end
41
+
42
+ module ReferencesPropertybaseIdColumn
43
+ extend ActiveSupport::Concern
44
+
45
+ included do
46
+ def references_with_propertybase_id(*args)
47
+ options = args.extract_options!
48
+ options.merge!(type: PB_ID_SQL_TYPE) if options[:type].to_s == "propertybase_id"
49
+ args << options
50
+ references_without_propertybase_id(*args)
51
+ end
52
+
53
+ alias_method_chain :references, :propertybase_id
54
+ end
55
+ end
56
+
29
57
  def self.apply!
30
58
  ActiveRecord::ConnectionAdapters::Table.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::Table
59
+ ActiveRecord::ConnectionAdapters::Table.send :include, ReferencesPropertybaseIdColumn if defined? ActiveRecord::ConnectionAdapters::Table
31
60
  ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::TableDefinition
61
+ ActiveRecord::ConnectionAdapters::TableDefinition.send :include, ReferencesPropertybaseIdColumn if defined? ActiveRecord::ConnectionAdapters::TableDefinition
32
62
  ActiveRecord::ConnectionAdapters::AlterTable.send :include, AddPropertybaseIdColumn
63
+
64
+ ActiveRecord::ConnectionAdapters::SchemaStatements.send :include, AddReferencePropertybaseIdColumn
33
65
  end
34
66
  end
35
67
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module PropertybaseId
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-propertybase_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leif Gensert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-20 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: propertybase_id
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.3
19
+ version: 0.4.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
- version: 0.3.3
26
+ version: 0.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement