person-name 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/lib/person-name.rb CHANGED
@@ -9,9 +9,6 @@ require "person_name/migration_support"
9
9
 
10
10
  $LOAD_PATH.shift
11
11
 
12
- if defined?(ActiveRecord::ConnectionAdapters::TableDefinition)
13
- ActiveRecord::ConnectionAdapters::TableDefinition.send :include, PersonName::MigrationSupport
14
- end
15
12
  if defined?(ActiveRecord::Base)
16
13
  ActiveRecord::Base.send :include, PersonName::ActiveRecord
17
14
  end
@@ -1,16 +1,17 @@
1
+ require 'active_record/connection_adapters/abstract_adapter'
1
2
 
2
- module PersonName::MigrationSupport
3
+ module ActiveRecord
4
+ module ConnectionAdapters
5
+ class TableDefinition
3
6
 
4
- def person_name(name, *args)
5
- self.add_name_columns(self, name, *args)
6
- end
7
+ def person_name(name, *args)
8
+ options = args.extract_options!
9
+ name_parts = PersonName::NameSplitter::NAME_PARTS
10
+ name_parts.each do |part|
11
+ column("#{name}_#{part}".to_sym, :string, :null => true)
12
+ end
13
+ end
7
14
 
8
- def self.add_name_columns(table, prefix, *args)
9
- options = args.extract_options!
10
- name_parts = PersonName::NameSplitter::NAME_PARTS
11
- name_parts.each do |part|
12
- table.column("#{prefix}_#{part}".to_sym, :string, :null => true)
13
15
  end
14
16
  end
15
-
16
17
  end
data/spec/schema.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ActiveRecord::Schema.define :version => 0 do
2
2
  create_table "people", :force => true do |t|
3
- PersonName::MigrationSupport.add_name_columns(t, :name)
3
+ t.person_name :name
4
4
  end
5
5
 
6
6
  create_table "person_without_names", :force => true do |t|
@@ -8,8 +8,8 @@ ActiveRecord::Schema.define :version => 0 do
8
8
  end
9
9
 
10
10
  create_table "name_people", :force => true do |t|
11
- PersonName::MigrationSupport.add_name_columns(t, :name)
12
- PersonName::MigrationSupport.add_name_columns(t, :birth_name)
11
+ t.person_name :name
12
+ t.person_name :birth_name
13
13
  t.boolean :female
14
14
  end
15
15
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: person-name
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthijs Groen