caber 0.3.1 → 0.4.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: 3e3022bcc88c31576a8e8f204063bb1cb3a3a2365cee60f5d5d8769779821719
4
- data.tar.gz: 9509f57e488c365e11cba921957db94d0f518e476f5457f56c8f12a39c160f54
3
+ metadata.gz: f6bda935480f7b69fe515d693078cec12122b527fee405b593f83bda85dc6ba8
4
+ data.tar.gz: afde1293ded688ea93031794a4197465e9d799aa17c6ac8c8b0dca7897135e60
5
5
  SHA512:
6
- metadata.gz: 6c3fb313ae9125c1bf96a857be7abc2b8c2dead1aa4a8e1c9347d08c3e3b2dbe634e6919dac1ccafb673e97002855d0b1ded604fc77d64e4da1b0055b8ba744e
7
- data.tar.gz: bb2d952b4fe708bc50194f167bf11cd01fdfdaf5d02a64a50a9c2cd8d3d8f66d0980d84f1c1922f54237cf216bd958788edbbe0b447f7229381c6bf211ed9f52
6
+ metadata.gz: fb3c8cbb9113114a4bb9d96686c839007b4809c445ead3a583d1f966a5ddb0aa1e824a612a49f31d517dcf167a56509327150182671b0d76ecee632a139c541e
7
+ data.tar.gz: 0dfa0445dbcfb9f78cf410b048b222809c6899ee31efe8ad12257468c1aac991ff552087913288638094e6f078bc853bf48db65ec551673dd99a76aa413e1e65
@@ -18,7 +18,9 @@ module Caber::Object
18
18
  end
19
19
 
20
20
  def grant_permission_to(permission, subject)
21
- Caber::Relation.create!(subject: subject, permission: permission, object: self)
21
+ rel = Caber::Relation.find_or_initialize_by(subject: subject, object: self)
22
+ rel.permission = permission
23
+ rel.save!
22
24
  end
23
25
 
24
26
  def grants_permission_to?(permission, subject)
data/lib/caber/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Caber
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -6,6 +6,7 @@ class CreateCaberRelations < ActiveRecord::Migration<%= migration_version %>
6
6
  t.references :object, polymorphic: true, null: false
7
7
 
8
8
  t.timestamps
9
+ t.index [:subject_id, :subject_type, :object_id, :object_type], unique: true
9
10
  end
10
11
  end
11
12
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-29 00:00:00.000000000 Z
11
+ date: 2024-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails