activerecord-propertybase_id 0.1.0 → 0.2.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: 4482c6bf93ce91a8badf8882964dcc5884dda017
4
- data.tar.gz: b19fec208329f02aa6c4a400a779b2b66432bb75
3
+ metadata.gz: 6b2198cfd17a6377ce1959968ebf3a3aac67b1cc
4
+ data.tar.gz: 59bb49f34e49c28efce1f059c823604441b9d521
5
5
  SHA512:
6
- metadata.gz: d798f4c99982ecaa66efa91d32b785af144d7bedce6a9ec7e69a03bedb5eed898153077a30e58beab2a3fd396921d8c2f953b765daa753047c10a882f8c316fa
7
- data.tar.gz: 4239c047ad3058046e810bce8aee9d865c8099c1b1d807716590d8223dc489ec9ad153acc65223128b53d109a6b98872a53be95fd79ed547e93f6564ff9b3356
6
+ metadata.gz: 9a0171a81ed4e44f36515ba7427d505943bfdee3dfb7be8b71a46bb0ceddf1c4d0d549fb41160c2ad5dcb7dbf2051476dc859603e1e72e116f61044a9d35b88f
7
+ data.tar.gz: b31e21c40ce98917e618e035b53835f4d2c16cd8bdb240763f29e0737bc09284e9d1b7a0fd0eb1943022279f7de2be6350e00e13bcebc5bbae6c2d28f2373a5c
@@ -1,20 +1,35 @@
1
1
  module ActiveRecord
2
2
  module PropertybaseId
3
3
  module Patches
4
+ PB_ID_SQL_TYPE = "char(#{::PropertybaseId.max_length})"
5
+
4
6
  module Migrations
5
7
  def propertybase_id(*column_names)
6
8
  options = column_names.extract_options!
7
9
  column_names.each do |name|
8
- type = "char(#{::PropertybaseId.max_length})"
9
10
  primary_key = options.delete(:primary_key) || name.to_s == "id"
10
- column(name, "#{type}#{' PRIMARY KEY' if primary_key}", options)
11
+ column(name, "#{PB_ID_SQL_TYPE}#{' PRIMARY KEY' if primary_key}", options)
11
12
  end
12
13
  end
13
14
  end
14
15
 
16
+ module AddPropertybaseIdColumn
17
+ extend ActiveSupport::Concern
18
+
19
+ included do
20
+ def add_column_with_propertybase_id(name, type, options)
21
+ type = PB_ID_SQL_TYPE if type.to_sym == :propertybase_id
22
+ add_column_without_propertybase_id(name, type, options)
23
+ end
24
+
25
+ alias_method_chain :add_column, :propertybase_id
26
+ end
27
+ end
28
+
15
29
  def self.apply!
16
30
  ActiveRecord::ConnectionAdapters::Table.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::Table
17
31
  ActiveRecord::ConnectionAdapters::TableDefinition.send :include, Migrations if defined? ActiveRecord::ConnectionAdapters::TableDefinition
32
+ ActiveRecord::ConnectionAdapters::AlterTable.send :include, AddPropertybaseIdColumn
18
33
  end
19
34
  end
20
35
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveRecord
2
2
  module PropertybaseId
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.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.1.0
4
+ version: 0.2.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-17 00:00:00.000000000 Z
11
+ date: 2015-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: propertybase_id