polivalente 0.5.2 → 0.6.0

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: 015f16377d9116c4e41fe6d31635e530e416f0edd53fcb123310e2d18281585b
4
- data.tar.gz: a2fdd33dbd1d15c85421636bc3578bb9cc0afab4f82db7a310e4025bc2d95fff
3
+ metadata.gz: 146bf51ffb686507752d9274f8a5d262a9e054cf950a8b8421c380d39e5cc3b6
4
+ data.tar.gz: b6e0bcf9c5c8e547161ad7055152845b6fc1a968d010c5d3ee634b212f47ef85
5
5
  SHA512:
6
- metadata.gz: 00060c4ab19051dc3ca5202ee0c6827e496feb010c0e4495de51bef8fb0b4c37b9a5d5f91c3fd0935c759ae52b5a32a8a508e11cd8299f2c49b87834cd43410a
7
- data.tar.gz: 98a4ac7172c92736199b6036a2c302eac0be2bc18a531ee2500e7dbbd4847d2f8fbbe28db7eeb557d78e5f3ac3dfeba481634c6e8fb244a35162622f5a7ed6b6
6
+ metadata.gz: 9bfd9568faede360eb560d5bfd8de1dab24dced76ef527186b068e16bf7708678a70829dab51bd6aa2bda7352fa156b604bf8ea85b044c305532d88e40457b57
7
+ data.tar.gz: c18b1b3423636bd0db2faa11c48aba56af50d2be08dcc9e8dd8d108b85504df3c782be8e74e2450edf54b19250aadb9318faf83e80ae9355f6d8dc2840ad06cf
@@ -0,0 +1,28 @@
1
+ module Polivalente
2
+ class Follow < ApplicationRecord
3
+ include Sortable
4
+
5
+ belongs_to :follower, class_name: Polivalente.config.user_class
6
+ belongs_to :followee, class_name: Polivalente.config.user_class
7
+
8
+ validates_presence_of :follower
9
+ validates_presence_of :followee
10
+ validate :not_following_yourself!
11
+
12
+ # broadcasts_to -> (follow) { "follows" }
13
+
14
+ def follower_name
15
+ follower.name
16
+ end
17
+
18
+ def followee_name
19
+ followee.name
20
+ end
21
+
22
+ private
23
+
24
+ def not_following_yourself!
25
+ errors.add "a user can only follow someone else" if follower == followee
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,12 @@
1
+ class CreateFollows < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :follows do |t|
4
+ t.references :follower, null: false, foreign_key: { to_table: :users, on_delete: :cascade }
5
+ t.references :followee, null: false, foreign_key: { to_table: :users, on_delete: :cascade }
6
+
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :follows, [:follower_id, :followee_id], unique: true, name: "index_unique_follow_relationship"
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module Polivalente
2
- VERSION = "0.5.2"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polivalente
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo Neto
@@ -155,6 +155,7 @@ files:
155
155
  - app/models/polivalente/application_record.rb
156
156
  - app/models/polivalente/archive.rb
157
157
  - app/models/polivalente/comment.rb
158
+ - app/models/polivalente/follow.rb
158
159
  - app/models/polivalente/reaction.rb
159
160
  - app/models/polivalente/tag.rb
160
161
  - app/models/polivalente/tagging.rb
@@ -176,6 +177,7 @@ files:
176
177
  - db/migrate/20220125144339_create_reactions.rb
177
178
  - db/migrate/20220125144342_create_trash.rb
178
179
  - db/migrate/20220130033524_create_archives.rb
180
+ - db/migrate/20220221013006_create_follows.rb
179
181
  - lib/generators/polivalente/controllers/controllers_generator.rb
180
182
  - lib/generators/polivalente/install/install_generator.rb
181
183
  - lib/generators/polivalente/templates/README