mappd 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 473cb92d742f731112c8443bacddf1e2dc92592940133fa9eaaa7de99a7754ca
4
- data.tar.gz: c995d4dbef38bae61681a966c6ffacf057f5f09705d497bbb97423e6881e63a2
3
+ metadata.gz: 311e0d6f33577daccff7700c6dfe76d5916d4e097a5ec75a96702470a9343796
4
+ data.tar.gz: 7be0bacb4267d823ae1a8849459ac549f1fc5e7ccf2cfc564663af53fb31f4bd
5
5
  SHA512:
6
- metadata.gz: c2abed12e72d3894bb419fd10f814426d4d029c6d2e28ef78dfad2ce2ab6d267865cd3b3dc31e57ac6e3291bf87df61b7c725d35dbc05600ccde96a23376acb3
7
- data.tar.gz: 5e6dec9fbafabb3fab482cc5a856289718625acac1022c9bdad9aaa9658b9314a034c6623e2c6870d13ca758ee7d2ff8f4ec3f6280415cbbe93bd9e3bba90076
6
+ metadata.gz: 0be5ee80c7200f3f30547dd1da1bcca24a801f6f720788be476ace98224c68fea00b40edf7a02b4b63fe252b076b3f264d03b9a60d31b2f8b7d1fad25e96b703
7
+ data.tar.gz: 94b10fcd3e7c8a059d756372179c9350bb0f14e4d0c16f19395f9e5807424c6e2902e465e809a92b89e8f908d558762f4742ffddc7ef4fb2e0285016ab2ed7a8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mappd (0.0.1.beta)
4
+ mappd (0.0.1)
5
5
  activerecord (>= 5.2.0)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # README
2
2
 
3
- Mappd is a replacement gem for [mini_record](https://github.com/DAddYE/mini_record). Mini record is great and I have been using it for a number of years. Unfortunately the mini_record report has not been updated in some time. With recent rails upgrades mini_record is not working well.
3
+ Mappd is a replacement gem for [mini_record](https://github.com/DAddYE/mini_record). Mini record is great and I have been using it for a number of years. Unfortunately the mini_record repo has not been updated in some time. With recent rails upgrades mini_record is not working well.
4
4
 
5
5
  Mappd is designed to work with ActiveRecord 5.2 >.
6
6
 
@@ -21,6 +21,8 @@ class Person < ActiveRecord::Base
21
21
  # Hooks into belongs_to and creates a country_id column
22
22
  # with an index
23
23
  belongs_to :country
24
+
25
+ has_many :pictures, as: :imageable
24
26
 
25
27
  # Creates a join table people_roles
26
28
  has_and_belongs_to_many :roles
@@ -32,8 +34,14 @@ class Person < ActiveRecord::Base
32
34
  timestamps
33
35
  end
34
36
 
37
+ class Picture < ActiveRecord::Base
38
+ # Creates a imageable_id and imageable_type
39
+ belongs_to :imageable, polymorphic: true
40
+ end
41
+
35
42
  class Country < ActiveRecord::Base
36
43
  field :name, :string
44
+ has_many :pictures, as: :imageable
37
45
  end
38
46
 
39
47
  class Role < ActiveRecord::Base
data/lib/mappd/mappd.rb CHANGED
@@ -24,7 +24,7 @@ module Mappd
24
24
  reflect_on_all_associations.each do |association|
25
25
  case association.macro
26
26
  when :belongs_to
27
- commands << [:add_reference, [table_name, association.name, {}]]
27
+ commands << [:add_reference, [table_name, association.name, association.options]]
28
28
  when :has_and_belongs_to_many
29
29
  commands << [:create_join_table,
30
30
  [table_name.to_sym, association.name]]
data/lib/mappd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mappd
2
- VERSION = '0.0.1'.freeze
2
+ VERSION = '0.0.2'.freeze
3
3
  end
data/spec/mappd_spec.rb CHANGED
@@ -37,3 +37,8 @@ RSpec.describe Person, type: :model do
37
37
  it { should have_db_column(:age).of_type(:string) }
38
38
  end
39
39
  end
40
+
41
+ RSpec.describe Picture, type: :model do
42
+ it { should have_db_column(:imageable_id).of_type(:integer) }
43
+ it { should have_db_column(:imageable_type).of_type(:string) }
44
+ end
data/spec/models.rb CHANGED
@@ -10,6 +10,7 @@ class Person < ActiveRecord::Base
10
10
  field :e_id, :string, length: 10
11
11
 
12
12
  belongs_to :country
13
+ has_many :pictures, as: :imageable
13
14
  has_and_belongs_to_many :roles
14
15
 
15
16
  index :e_id
@@ -17,8 +18,13 @@ class Person < ActiveRecord::Base
17
18
  timestamps
18
19
  end
19
20
 
21
+ class Picture < ActiveRecord::Base
22
+ belongs_to :imageable, polymorphic: true
23
+ end
24
+
20
25
  class Country < ActiveRecord::Base
21
26
  field :name, :string
27
+ has_many :pictures, as: :imageable
22
28
  end
23
29
 
24
30
  class Role < ActiveRecord::Base
@@ -29,3 +35,4 @@ end
29
35
  Person.migrate!
30
36
  Country.migrate!
31
37
  Role.migrate!
38
+ Picture.migrate!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mappd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Watson