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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +1 -1
- data/README.md +3 -5
- data/activerecord-propertybase_id.gemspec +1 -1
- data/lib/activerecord/propertybase_id/patches.rb +33 -1
- data/lib/activerecord/propertybase_id/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26f5a4e1850a56a83d8c6000780eaa95f7fb63cc
|
4
|
+
data.tar.gz: f1528ea64f6392619ada3b46ea1bb6c1e714902e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98b5137743e268d3fe435913aac6bf25f25f1df08b6507d94c003fb50b17bdd221c8d35847098783176162be352f4b5daeb223e6cd61956595cc5aa5dfcea774
|
7
|
+
data.tar.gz: 08e5d12ffcf030d7e15a4802fa3b6e32cc25a73ae129cee31c1caa4ebd70b434762b95006fac468ce5342f0016bb4e43fd86c09ec0e9298d28489c5c6a2b0e44
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# ActiveRecord::PropertybaseId
|
2
2
|
|
3
|
-
|
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(
|
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
|
-
##
|
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.
|
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.
|
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
|
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.
|
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-
|
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.
|
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.
|
26
|
+
version: 0.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|