dynamican 0.1.9 → 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
  SHA256:
3
- metadata.gz: 2919c67cd907ca110db119ff27da8eb0ab7dc7fef6d9911de9b2ed04fdd111e2
4
- data.tar.gz: 3e89dcbe20185469f70b2d066264f848be3c8ef92b0f9e18771a9b6bc23d69a3
3
+ metadata.gz: 3229463775ada8d5f0a281fadf656089554b8f155ed282fab690134c918666bf
4
+ data.tar.gz: 74a027bece14bfa3555c70ca9baa54d265d7110184e6c43bab0d2a1e5bbfd911
5
5
  SHA512:
6
- metadata.gz: f97e9268851d07d730e2d4cada589ed6c35ae57f8d127854d4199cd93b464dd1de342c6b9e674434be535a09ca9be8a52ad811d0fde348c846148b0c62494c3e
7
- data.tar.gz: 35b2f9fe8360a9cbd4e9627b9a4249ee6aca206d6a394f2a8909ea8b74e53605eb64cc04119d1c11ad0d871a06d85313c81d2e89c1faa6bba2d17b79714a0411
6
+ metadata.gz: 7f903194f76b1a0324e175dc4c896827d35244ed43281ff2e148d3779bd3f3207948d57af6afe484dae703ab34bcaf04e7fdff1fc711f6a6398d9a0079bd3a8a
7
+ data.tar.gz: 6c06f2340a7807b90e1a50cf010a72ba1c4725387094502622aee686059e0bfb374bcff26ef756cf2b06484e66fc1382d3ac5f26890c97e0f54a28c4ac85b309
data/README.md CHANGED
@@ -22,10 +22,14 @@ Create `config/dynamican.yml` file in your project and compile it as follows for
22
22
 
23
23
  Once this config file is created, you can launch the following command.
24
24
 
25
- rails generate dynamican_migration
25
+ rails g dynamican_migration
26
26
 
27
27
  This command will generate a migration file in your project. Inside this migration, the `permission_connectors` table will have a reference column for the models you configured in the config file. If you want to add the feature to a new model after your migrations are already run (and cannot be rollbacked) you need to create a new migration to add the corresponding columns in the `permission_connectors` table.
28
28
 
29
+ Now that you have your migration, just migrate.
30
+
31
+ rails db:migrate
32
+
29
33
  ### Using a model permissions on another model
30
34
 
31
35
  I wanted to have the possibility to assign permissions both directly to my User model and my Role model, so that if the User had one permission and one of its Role had another, the User could benefit from both. So i assigned the feature (as explained above) to both models and then decorated my User model like following.
data/dynamican.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'dynamican'
3
- s.version = '0.1.9'
3
+ s.version = '0.2.0'
4
4
  s.date = '2020-04-18'
5
5
  s.summary = "Dynamic permissions"
6
6
  s.description = "Dynamic and flexible database configurable permissions for your application"
@@ -23,7 +23,7 @@ module Dynamican
23
23
  private
24
24
 
25
25
  def set_instance_variables
26
- instance_variable_set("@#{subject.model_name.element}", subject)
26
+ instance_variable_set("@#{subject.class.name.demodulize.underscore}", subject)
27
27
 
28
28
  conditions_instances.each do |instance_name, instance_object|
29
29
  instance_variable_set("@#{instance_name}", instance_object)
@@ -36,7 +36,7 @@ module Dynamican
36
36
  elsif object.is_a?(NilClass)
37
37
  nil
38
38
  else
39
- object.class.to_s.downcase
39
+ object.class.name.demodulize.underscore
40
40
  end
41
41
  end
42
42
  end
@@ -1,7 +1,7 @@
1
1
  module Dynamican
2
2
  class PermissionConnector < ActiveRecord::Base
3
3
  Dynamican.configuration.associations.each do |association_name, association_options|
4
- belongs_to association_name.to_sym, class_name: association_options[:class_name], inverse_of: association_options[:inverse_of], foreign_key: "#{association_name}_id".to_sym, optional: true
4
+ belongs_to association_name.to_sym, class_name: association_options[:class_name], inverse_of: :permission_connectors, foreign_key: "#{association_name}_id".to_sym, optional: true
5
5
  end
6
6
  has_and_belongs_to_many :conditions, class_name: 'Dynamican::Condition', inverse_of: :permission_connectors, foreign_key: :permission_connector_id
7
7
  belongs_to :permission, class_name: 'Dynamican::Permission', inverse_of: :permission_connectors, foreign_key: :permission_id
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamican
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valerio Bellaveglia