monarchy 2.1.0 → 2.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 +4 -4
- data/.rubocop.yml +7 -1
- data/Gemfile +6 -5
- data/Gemfile.lock +55 -55
- data/Rakefile +1 -0
- data/app/models/monarchy/hierarchy.rb +1 -0
- data/app/models/monarchy/member.rb +1 -0
- data/app/models/monarchy/members_role.rb +1 -0
- data/app/models/monarchy/role.rb +1 -0
- data/docs/acts_as_hierarchy.md +9 -0
- data/docs/acts_as_resource.md +8 -0
- data/dummy/Rakefile +1 -0
- data/dummy/app/controllers/application_controller.rb +1 -0
- data/dummy/app/helpers/application_helper.rb +1 -0
- data/dummy/app/models/member.rb +1 -0
- data/dummy/app/models/memo.rb +1 -0
- data/dummy/app/models/project.rb +1 -0
- data/dummy/app/models/resource.rb +1 -0
- data/dummy/app/models/role.rb +1 -0
- data/dummy/app/models/status.rb +1 -0
- data/dummy/app/models/task.rb +1 -0
- data/dummy/app/models/user.rb +1 -0
- data/dummy/bin/bundle +1 -0
- data/dummy/bin/rails +1 -0
- data/dummy/bin/rake +1 -0
- data/dummy/bin/setup +1 -0
- data/dummy/config/application.rb +1 -0
- data/dummy/config/boot.rb +1 -0
- data/dummy/config/environment.rb +1 -0
- data/dummy/config/environments/development.rb +1 -0
- data/dummy/config/environments/production.rb +1 -0
- data/dummy/config/environments/test.rb +1 -0
- data/dummy/config/initializers/assets.rb +1 -0
- data/dummy/config/initializers/cookies_serializer.rb +1 -0
- data/dummy/config/initializers/filter_parameter_logging.rb +1 -0
- data/dummy/config/initializers/monarchy.rb +1 -0
- data/dummy/config/initializers/session_store.rb +1 -0
- data/dummy/config/initializers/wrap_parameters.rb +1 -0
- data/dummy/config/routes.rb +1 -0
- data/dummy/config.ru +1 -0
- data/lib/generators/monarchy/resource_generator.rb +1 -0
- data/lib/generators/monarchy/setup_generator.rb +1 -0
- data/lib/monarchy/acts_as_hierarchy.rb +9 -0
- data/lib/monarchy/acts_as_member.rb +2 -1
- data/lib/monarchy/acts_as_resource.rb +5 -0
- data/lib/monarchy/acts_as_role.rb +1 -0
- data/lib/monarchy/acts_as_user.rb +2 -1
- data/lib/monarchy/engine.rb +1 -0
- data/lib/monarchy/exceptions.rb +1 -0
- data/lib/monarchy/tasks.rb +1 -0
- data/lib/monarchy/validators.rb +1 -0
- data/lib/monarchy/version.rb +2 -1
- data/lib/monarchy.rb +1 -0
- data/monarchy.gemspec +3 -2
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4734b0ccb0db7937722f2fa64a0bbe4d47c65cb7
         | 
| 4 | 
            +
              data.tar.gz: f7b5fa3002944a30b7eba6e2404c958c4c0762d9
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9f3aa4a7caa467471faa25ff5ed132db52f9c4c82f21786f3191a8d9ad0ebdca134a55cc1bd6927bee27c208cd04bbc0b5716c256d9aa9183ef3246f574524d5
         | 
| 7 | 
            +
              data.tar.gz: 40faced1c717c0329ea1ce5da56c533ed309e05baac0d3df4e36fec148633c5959775c619fcaf06dbb1738f0704f163f1964b4e8c6296c6444fc5afb8ade4690
         | 
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            AllCops:
         | 
| 2 | 
            -
              TargetRubyVersion: 2. | 
| 2 | 
            +
              TargetRubyVersion: 2.3
         | 
| 3 3 | 
             
              Exclude:
         | 
| 4 4 | 
             
               - 'dummy/db/seeds.rb'
         | 
| 5 5 | 
             
               - 'dummy/db/migrate/**'
         | 
| @@ -21,3 +21,9 @@ Style/ClassAndModuleChildren: | |
| 21 21 | 
             
              Enabled: false
         | 
| 22 22 | 
             
            Rails/HasAndBelongsToMany:
         | 
| 23 23 | 
             
              Enabled: false
         | 
| 24 | 
            +
            Style/MixinGrouping:
         | 
| 25 | 
            +
              Exclude:
         | 
| 26 | 
            +
                - 'spec/**/*.rb'
         | 
| 27 | 
            +
            Lint/AmbiguousBlockAssociation:
         | 
| 28 | 
            +
              Exclude:
         | 
| 29 | 
            +
                - 'spec/**/*.rb'
         | 
    
        data/Gemfile
    CHANGED
    
    | @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            source 'https://rubygems.org'
         | 
| 3 4 | 
             
            ruby '2.4.0'
         | 
| 4 5 |  | 
| @@ -18,14 +19,14 @@ gemspec | |
| 18 19 | 
             
            group :development, :test do
         | 
| 19 20 | 
             
              gem 'database_cleaner', '1.5.3'
         | 
| 20 21 | 
             
              gem 'factory_girl_rails', '4.8.0'
         | 
| 21 | 
            -
              gem 'ffaker', '2. | 
| 22 | 
            -
              gem 'pry-rails', '0.3. | 
| 23 | 
            -
              gem 'rails', '5.0. | 
| 22 | 
            +
              gem 'ffaker', '2.5.0'
         | 
| 23 | 
            +
              gem 'pry-rails', '0.3.6'
         | 
| 24 | 
            +
              gem 'rails', '5.0.2'
         | 
| 24 25 | 
             
              gem 'rspec-rails', '3.5.2'
         | 
| 25 | 
            -
              gem 'rubocop', '0. | 
| 26 | 
            +
              gem 'rubocop', '0.48.0'
         | 
| 26 27 | 
             
              gem 'shoulda-matchers', '3.1.1'
         | 
| 27 28 | 
             
              gem 'sqlite3', '1.3.13'
         | 
| 28 29 | 
             
            end
         | 
| 29 30 |  | 
| 30 | 
            -
            gem 'codeclimate-test-reporter', '~>1.0. | 
| 31 | 
            +
            gem 'codeclimate-test-reporter', '~>1.0.8', group: :test
         | 
| 31 32 | 
             
            gem 'simplecov', '0.13.0', group: :test
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,51 +1,51 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                monarchy (2. | 
| 4 | 
            +
                monarchy (2.2.0)
         | 
| 5 5 | 
             
                  active_record_union (= 1.2.0)
         | 
| 6 6 | 
             
                  activerecord (>= 4.2.7.1)
         | 
| 7 | 
            -
                  closure_tree (= 6. | 
| 7 | 
            +
                  closure_tree (= 6.5.0)
         | 
| 8 8 | 
             
                  configurations (= 2.2.2)
         | 
| 9 9 | 
             
                  tqdm (= 0.3.0)
         | 
| 10 10 |  | 
| 11 11 | 
             
            GEM
         | 
| 12 12 | 
             
              remote: https://rubygems.org/
         | 
| 13 13 | 
             
              specs:
         | 
| 14 | 
            -
                actioncable (5.0. | 
| 15 | 
            -
                  actionpack (= 5.0. | 
| 16 | 
            -
                  nio4r ( | 
| 14 | 
            +
                actioncable (5.0.2)
         | 
| 15 | 
            +
                  actionpack (= 5.0.2)
         | 
| 16 | 
            +
                  nio4r (>= 1.2, < 3.0)
         | 
| 17 17 | 
             
                  websocket-driver (~> 0.6.1)
         | 
| 18 | 
            -
                actionmailer (5.0. | 
| 19 | 
            -
                  actionpack (= 5.0. | 
| 20 | 
            -
                  actionview (= 5.0. | 
| 21 | 
            -
                  activejob (= 5.0. | 
| 18 | 
            +
                actionmailer (5.0.2)
         | 
| 19 | 
            +
                  actionpack (= 5.0.2)
         | 
| 20 | 
            +
                  actionview (= 5.0.2)
         | 
| 21 | 
            +
                  activejob (= 5.0.2)
         | 
| 22 22 | 
             
                  mail (~> 2.5, >= 2.5.4)
         | 
| 23 23 | 
             
                  rails-dom-testing (~> 2.0)
         | 
| 24 | 
            -
                actionpack (5.0. | 
| 25 | 
            -
                  actionview (= 5.0. | 
| 26 | 
            -
                  activesupport (= 5.0. | 
| 24 | 
            +
                actionpack (5.0.2)
         | 
| 25 | 
            +
                  actionview (= 5.0.2)
         | 
| 26 | 
            +
                  activesupport (= 5.0.2)
         | 
| 27 27 | 
             
                  rack (~> 2.0)
         | 
| 28 28 | 
             
                  rack-test (~> 0.6.3)
         | 
| 29 29 | 
             
                  rails-dom-testing (~> 2.0)
         | 
| 30 30 | 
             
                  rails-html-sanitizer (~> 1.0, >= 1.0.2)
         | 
| 31 | 
            -
                actionview (5.0. | 
| 32 | 
            -
                  activesupport (= 5.0. | 
| 31 | 
            +
                actionview (5.0.2)
         | 
| 32 | 
            +
                  activesupport (= 5.0.2)
         | 
| 33 33 | 
             
                  builder (~> 3.1)
         | 
| 34 34 | 
             
                  erubis (~> 2.7.0)
         | 
| 35 35 | 
             
                  rails-dom-testing (~> 2.0)
         | 
| 36 | 
            -
                  rails-html-sanitizer (~> 1.0, >= 1.0. | 
| 36 | 
            +
                  rails-html-sanitizer (~> 1.0, >= 1.0.3)
         | 
| 37 37 | 
             
                active_record_union (1.2.0)
         | 
| 38 38 | 
             
                  activerecord (>= 4.0)
         | 
| 39 | 
            -
                activejob (5.0. | 
| 40 | 
            -
                  activesupport (= 5.0. | 
| 39 | 
            +
                activejob (5.0.2)
         | 
| 40 | 
            +
                  activesupport (= 5.0.2)
         | 
| 41 41 | 
             
                  globalid (>= 0.3.6)
         | 
| 42 | 
            -
                activemodel (5.0. | 
| 43 | 
            -
                  activesupport (= 5.0. | 
| 44 | 
            -
                activerecord (5.0. | 
| 45 | 
            -
                  activemodel (= 5.0. | 
| 46 | 
            -
                  activesupport (= 5.0. | 
| 42 | 
            +
                activemodel (5.0.2)
         | 
| 43 | 
            +
                  activesupport (= 5.0.2)
         | 
| 44 | 
            +
                activerecord (5.0.2)
         | 
| 45 | 
            +
                  activemodel (= 5.0.2)
         | 
| 46 | 
            +
                  activesupport (= 5.0.2)
         | 
| 47 47 | 
             
                  arel (~> 7.0)
         | 
| 48 | 
            -
                activesupport (5.0. | 
| 48 | 
            +
                activesupport (5.0.2)
         | 
| 49 49 | 
             
                  concurrent-ruby (~> 1.0, >= 1.0.2)
         | 
| 50 50 | 
             
                  i18n (~> 0.7)
         | 
| 51 51 | 
             
                  minitest (~> 5.1)
         | 
| @@ -53,13 +53,13 @@ GEM | |
| 53 53 | 
             
                arel (7.1.4)
         | 
| 54 54 | 
             
                ast (2.3.0)
         | 
| 55 55 | 
             
                builder (3.2.3)
         | 
| 56 | 
            -
                closure_tree (6. | 
| 56 | 
            +
                closure_tree (6.5.0)
         | 
| 57 57 | 
             
                  activerecord (>= 4.1.0)
         | 
| 58 58 | 
             
                  with_advisory_lock (>= 3.0.0)
         | 
| 59 | 
            -
                codeclimate-test-reporter (1.0. | 
| 60 | 
            -
                  simplecov
         | 
| 59 | 
            +
                codeclimate-test-reporter (1.0.8)
         | 
| 60 | 
            +
                  simplecov (<= 0.13)
         | 
| 61 61 | 
             
                coderay (1.1.1)
         | 
| 62 | 
            -
                concurrent-ruby (1.0. | 
| 62 | 
            +
                concurrent-ruby (1.0.5)
         | 
| 63 63 | 
             
                configurations (2.2.2)
         | 
| 64 64 | 
             
                database_cleaner (1.5.3)
         | 
| 65 65 | 
             
                diff-lcs (1.3)
         | 
| @@ -70,10 +70,10 @@ GEM | |
| 70 70 | 
             
                factory_girl_rails (4.8.0)
         | 
| 71 71 | 
             
                  factory_girl (~> 4.8.0)
         | 
| 72 72 | 
             
                  railties (>= 3.0.0)
         | 
| 73 | 
            -
                ffaker (2. | 
| 73 | 
            +
                ffaker (2.5.0)
         | 
| 74 74 | 
             
                globalid (0.3.7)
         | 
| 75 75 | 
             
                  activesupport (>= 4.1.0)
         | 
| 76 | 
            -
                i18n (0.8. | 
| 76 | 
            +
                i18n (0.8.1)
         | 
| 77 77 | 
             
                json (2.0.3)
         | 
| 78 78 | 
             
                loofah (2.0.3)
         | 
| 79 79 | 
             
                  nokogiri (>= 1.5.9)
         | 
| @@ -85,8 +85,8 @@ GEM | |
| 85 85 | 
             
                mime-types-data (3.2016.0521)
         | 
| 86 86 | 
             
                mini_portile2 (2.1.0)
         | 
| 87 87 | 
             
                minitest (5.10.1)
         | 
| 88 | 
            -
                nio4r ( | 
| 89 | 
            -
                nokogiri (1.7. | 
| 88 | 
            +
                nio4r (2.0.0)
         | 
| 89 | 
            +
                nokogiri (1.7.1)
         | 
| 90 90 | 
             
                  mini_portile2 (~> 2.1.0)
         | 
| 91 91 | 
             
                parser (2.4.0.0)
         | 
| 92 92 | 
             
                  ast (~> 2.2)
         | 
| @@ -95,31 +95,31 @@ GEM | |
| 95 95 | 
             
                  coderay (~> 1.1.0)
         | 
| 96 96 | 
             
                  method_source (~> 0.8.1)
         | 
| 97 97 | 
             
                  slop (~> 3.4)
         | 
| 98 | 
            -
                pry-rails (0.3. | 
| 99 | 
            -
                  pry (>= 0. | 
| 98 | 
            +
                pry-rails (0.3.6)
         | 
| 99 | 
            +
                  pry (>= 0.10.4)
         | 
| 100 100 | 
             
                rack (2.0.1)
         | 
| 101 101 | 
             
                rack-test (0.6.3)
         | 
| 102 102 | 
             
                  rack (>= 1.0)
         | 
| 103 | 
            -
                rails (5.0. | 
| 104 | 
            -
                  actioncable (= 5.0. | 
| 105 | 
            -
                  actionmailer (= 5.0. | 
| 106 | 
            -
                  actionpack (= 5.0. | 
| 107 | 
            -
                  actionview (= 5.0. | 
| 108 | 
            -
                  activejob (= 5.0. | 
| 109 | 
            -
                  activemodel (= 5.0. | 
| 110 | 
            -
                  activerecord (= 5.0. | 
| 111 | 
            -
                  activesupport (= 5.0. | 
| 103 | 
            +
                rails (5.0.2)
         | 
| 104 | 
            +
                  actioncable (= 5.0.2)
         | 
| 105 | 
            +
                  actionmailer (= 5.0.2)
         | 
| 106 | 
            +
                  actionpack (= 5.0.2)
         | 
| 107 | 
            +
                  actionview (= 5.0.2)
         | 
| 108 | 
            +
                  activejob (= 5.0.2)
         | 
| 109 | 
            +
                  activemodel (= 5.0.2)
         | 
| 110 | 
            +
                  activerecord (= 5.0.2)
         | 
| 111 | 
            +
                  activesupport (= 5.0.2)
         | 
| 112 112 | 
             
                  bundler (>= 1.3.0, < 2.0)
         | 
| 113 | 
            -
                  railties (= 5.0. | 
| 113 | 
            +
                  railties (= 5.0.2)
         | 
| 114 114 | 
             
                  sprockets-rails (>= 2.0.0)
         | 
| 115 115 | 
             
                rails-dom-testing (2.0.2)
         | 
| 116 116 | 
             
                  activesupport (>= 4.2.0, < 6.0)
         | 
| 117 117 | 
             
                  nokogiri (~> 1.6)
         | 
| 118 118 | 
             
                rails-html-sanitizer (1.0.3)
         | 
| 119 119 | 
             
                  loofah (~> 2.0)
         | 
| 120 | 
            -
                railties (5.0. | 
| 121 | 
            -
                  actionpack (= 5.0. | 
| 122 | 
            -
                  activesupport (= 5.0. | 
| 120 | 
            +
                railties (5.0.2)
         | 
| 121 | 
            +
                  actionpack (= 5.0.2)
         | 
| 122 | 
            +
                  activesupport (= 5.0.2)
         | 
| 123 123 | 
             
                  method_source
         | 
| 124 124 | 
             
                  rake (>= 0.8.7)
         | 
| 125 125 | 
             
                  thor (>= 0.18.1, < 2.0)
         | 
| @@ -146,7 +146,7 @@ GEM | |
| 146 146 | 
             
                  rspec-mocks (~> 3.5.0)
         | 
| 147 147 | 
             
                  rspec-support (~> 3.5.0)
         | 
| 148 148 | 
             
                rspec-support (3.5.0)
         | 
| 149 | 
            -
                rubocop (0. | 
| 149 | 
            +
                rubocop (0.48.0)
         | 
| 150 150 | 
             
                  parser (>= 2.3.3.1, < 3.0)
         | 
| 151 151 | 
             
                  powerpack (~> 0.1)
         | 
| 152 152 | 
             
                  rainbow (>= 1.99.1, < 3.0)
         | 
| @@ -170,15 +170,15 @@ GEM | |
| 170 170 | 
             
                  sprockets (>= 3.0.0)
         | 
| 171 171 | 
             
                sqlite3 (1.3.13)
         | 
| 172 172 | 
             
                thor (0.19.4)
         | 
| 173 | 
            -
                thread_safe (0.3. | 
| 173 | 
            +
                thread_safe (0.3.6)
         | 
| 174 174 | 
             
                tqdm (0.3.0)
         | 
| 175 | 
            -
                tzinfo (1.2. | 
| 175 | 
            +
                tzinfo (1.2.3)
         | 
| 176 176 | 
             
                  thread_safe (~> 0.1)
         | 
| 177 177 | 
             
                unicode-display_width (1.1.3)
         | 
| 178 178 | 
             
                websocket-driver (0.6.5)
         | 
| 179 179 | 
             
                  websocket-extensions (>= 0.1.0)
         | 
| 180 180 | 
             
                websocket-extensions (0.1.2)
         | 
| 181 | 
            -
                with_advisory_lock (3. | 
| 181 | 
            +
                with_advisory_lock (3.1.0)
         | 
| 182 182 | 
             
                  activerecord (>= 3.2)
         | 
| 183 183 | 
             
                  thread_safe
         | 
| 184 184 |  | 
| @@ -187,17 +187,17 @@ PLATFORMS | |
| 187 187 |  | 
| 188 188 | 
             
            DEPENDENCIES
         | 
| 189 189 | 
             
              bundler (~> 1.12)
         | 
| 190 | 
            -
              codeclimate-test-reporter (~> 1.0. | 
| 190 | 
            +
              codeclimate-test-reporter (~> 1.0.8)
         | 
| 191 191 | 
             
              database_cleaner (= 1.5.3)
         | 
| 192 192 | 
             
              factory_girl_rails (= 4.8.0)
         | 
| 193 | 
            -
              ffaker (= 2. | 
| 193 | 
            +
              ffaker (= 2.5.0)
         | 
| 194 194 | 
             
              monarchy!
         | 
| 195 | 
            -
              pry-rails (= 0.3. | 
| 196 | 
            -
              rails (= 5.0. | 
| 195 | 
            +
              pry-rails (= 0.3.6)
         | 
| 196 | 
            +
              rails (= 5.0.2)
         | 
| 197 197 | 
             
              rake (~> 12.0)
         | 
| 198 198 | 
             
              rspec (= 3.5.0)
         | 
| 199 199 | 
             
              rspec-rails (= 3.5.2)
         | 
| 200 | 
            -
              rubocop (= 0. | 
| 200 | 
            +
              rubocop (= 0.48.0)
         | 
| 201 201 | 
             
              shoulda-matchers (= 3.1.1)
         | 
| 202 202 | 
             
              simplecov (= 0.13.0)
         | 
| 203 203 | 
             
              sqlite3 (= 1.3.13)
         | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/app/models/monarchy/role.rb
    CHANGED
    
    
    
        data/docs/acts_as_hierarchy.md
    CHANGED
    
    | @@ -4,6 +4,15 @@ | |
| 4 4 | 
             
            > hmm... sounds like `private`
         | 
| 5 5 |  | 
| 6 6 | 
             
            ## Methods
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ### #accessible_for
         | 
| 9 | 
            +
            You can check if user has an access to the hierarchy by calling `accessible_for(user, options = {})` on hierarchy instance, eg:
         | 
| 10 | 
            +
            ```ruby
         | 
| 11 | 
            +
            resource_hierarchy.accessible_for(user) # returns TRUE or FALSE
         | 
| 12 | 
            +
            ```
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            Optionally, you can pass an `options` argument to specify custom strategy.
         | 
| 15 | 
            +
             | 
| 7 16 | 
             
            ** We do not recommend to use it but if yo have to: **
         | 
| 8 17 | 
             
            We are using [Closure Tree][e5c808aa] behind `Hierarchy` class. There is a bunch of methods and functions available behind the hood. Check their documentation.
         | 
| 9 18 |  | 
    
        data/docs/acts_as_resource.md
    CHANGED
    
    | @@ -62,6 +62,14 @@ Returns default role name for the class | |
| 62 62 | 
             
            ### .default_role
         | 
| 63 63 | 
             
            Returns default role object `Monarchy::Role` for the class
         | 
| 64 64 |  | 
| 65 | 
            +
            ### #accessible_for
         | 
| 66 | 
            +
            You can check if user has an access to the resource by calling `accessible_for(user, options = {})` on resource instance, eg:
         | 
| 67 | 
            +
            ```ruby
         | 
| 68 | 
            +
            resource.accessible_for(user) # returns TRUE or FALSE
         | 
| 69 | 
            +
            ```
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            Optionally, you can pass an `options` argument to specify custom strategy.
         | 
| 72 | 
            +
             | 
| 65 73 | 
             
            ### Scopes:
         | 
| 66 74 |  | 
| 67 75 | 
             
            ### .accessible_for
         | 
    
        data/dummy/Rakefile
    CHANGED
    
    
    
        data/dummy/app/models/member.rb
    CHANGED
    
    
    
        data/dummy/app/models/memo.rb
    CHANGED
    
    
    
        data/dummy/app/models/project.rb
    CHANGED
    
    
    
        data/dummy/app/models/role.rb
    CHANGED
    
    
    
        data/dummy/app/models/status.rb
    CHANGED
    
    
    
        data/dummy/app/models/task.rb
    CHANGED
    
    
    
        data/dummy/app/models/user.rb
    CHANGED
    
    
    
        data/dummy/bin/bundle
    CHANGED
    
    
    
        data/dummy/bin/rails
    CHANGED
    
    
    
        data/dummy/bin/rake
    CHANGED
    
    
    
        data/dummy/bin/setup
    CHANGED
    
    
    
        data/dummy/config/application.rb
    CHANGED
    
    
    
        data/dummy/config/boot.rb
    CHANGED
    
    
    
        data/dummy/config/environment.rb
    CHANGED
    
    
    
        data/dummy/config/routes.rb
    CHANGED
    
    
    
        data/dummy/config.ru
    CHANGED
    
    
| @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            module Monarchy
         | 
| 3 4 | 
             
              module ActsAsHierarchy
         | 
| 4 5 | 
             
                extend ActiveSupport::Concern
         | 
| @@ -17,6 +18,14 @@ module Monarchy | |
| 17 18 |  | 
| 18 19 | 
             
                    validates :resource_type, presence: true
         | 
| 19 20 | 
             
                    validates :resource_id, uniqueness: { scope: [:resource_type] }, presence: true
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                    include Monarchy::ActsAsHierarchy::InstanceMethods
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                module InstanceMethods
         | 
| 27 | 
            +
                  def accessible_for(user, options = {})
         | 
| 28 | 
            +
                    self.class.accessible_for(user, options).find_by(id: id).present?
         | 
| 20 29 | 
             
                  end
         | 
| 21 30 | 
             
                end
         | 
| 22 31 |  | 
| @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            module Monarchy
         | 
| 3 4 | 
             
              module ActsAsMember
         | 
| 4 5 | 
             
                extend ActiveSupport::Concern
         | 
| @@ -29,7 +30,7 @@ module Monarchy | |
| 29 30 |  | 
| 30 31 | 
             
                    scope :with_access_to, (lambda do |resource|
         | 
| 31 32 | 
             
                      Monarchy::Validators.resource(resource)
         | 
| 32 | 
            -
                      with_ancestors_access(resource).union(with_descendants_access(resource))
         | 
| 33 | 
            +
                      where(id: with_ancestors_access(resource).union(with_descendants_access(resource)))
         | 
| 33 34 | 
             
                    end)
         | 
| 34 35 | 
             
                  end
         | 
| 35 36 |  | 
| @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            module Monarchy
         | 
| 3 4 | 
             
              module ActsAsResource
         | 
| 4 5 | 
             
                extend ActiveSupport::Concern
         | 
| @@ -94,6 +95,10 @@ module Monarchy | |
| 94 95 | 
             
                    )
         | 
| 95 96 | 
             
                  end
         | 
| 96 97 |  | 
| 98 | 
            +
                  def accessible_for(user)
         | 
| 99 | 
            +
                    hierarchy.accessible_for(user)
         | 
| 100 | 
            +
                  end
         | 
| 101 | 
            +
             | 
| 97 102 | 
             
                  private
         | 
| 98 103 |  | 
| 99 104 | 
             
                  def assign_parent(force = false)
         | 
| @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            module Monarchy
         | 
| 3 4 | 
             
              module ActsAsUser
         | 
| 4 5 | 
             
                extend ActiveSupport::Concern
         | 
| @@ -23,7 +24,7 @@ module Monarchy | |
| 23 24 | 
             
                    end)
         | 
| 24 25 |  | 
| 25 26 | 
             
                    scope :with_access_to, (lambda do |resource|
         | 
| 26 | 
            -
                       | 
| 27 | 
            +
                      where(id: Monarchy.member_class.with_access_to(resource).select(:user_id))
         | 
| 27 28 | 
             
                    end)
         | 
| 28 29 | 
             
                  end
         | 
| 29 30 | 
             
                end
         | 
    
        data/lib/monarchy/engine.rb
    CHANGED
    
    
    
        data/lib/monarchy/exceptions.rb
    CHANGED
    
    
    
        data/lib/monarchy/tasks.rb
    CHANGED
    
    
    
        data/lib/monarchy/validators.rb
    CHANGED
    
    
    
        data/lib/monarchy/version.rb
    CHANGED
    
    
    
        data/lib/monarchy.rb
    CHANGED
    
    
    
        data/monarchy.gemspec
    CHANGED
    
    | @@ -1,5 +1,6 @@ | |
| 1 1 | 
             
            # coding: utf-8
         | 
| 2 2 | 
             
            # frozen_string_literal: true
         | 
| 3 | 
            +
             | 
| 3 4 | 
             
            lib = File.expand_path('../lib', __FILE__)
         | 
| 4 5 | 
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 5 6 | 
             
            require 'monarchy/version'
         | 
| @@ -9,7 +10,7 @@ Gem::Specification.new do |s| | |
| 9 10 | 
             
              s.name        = 'monarchy'
         | 
| 10 11 | 
             
              s.version     = Monarchy::VERSION
         | 
| 11 12 | 
             
              s.authors     = ['Exelord']
         | 
| 12 | 
            -
              s.email       = ['']
         | 
| 13 | 
            +
              s.email       = ['exelord@macsour.com']
         | 
| 13 14 | 
             
              s.homepage    = 'https://github.com/Exelord/Monarchy'
         | 
| 14 15 | 
             
              s.summary     = 'Hierarchical access management system with roles inheritance.'
         | 
| 15 16 | 
             
              s.description = s.summary
         | 
| @@ -27,7 +28,7 @@ Gem::Specification.new do |s| | |
| 27 28 | 
             
              s.required_ruby_version = '>= 2.3'
         | 
| 28 29 |  | 
| 29 30 | 
             
              s.add_dependency 'activerecord', '>=4.2.7.1'
         | 
| 30 | 
            -
              s.add_dependency 'closure_tree', '6. | 
| 31 | 
            +
              s.add_dependency 'closure_tree', '6.5.0'
         | 
| 31 32 | 
             
              s.add_dependency 'configurations', '2.2.2'
         | 
| 32 33 | 
             
              s.add_dependency 'active_record_union', '1.2.0'
         | 
| 33 34 | 
             
              s.add_dependency 'tqdm', '0.3.0'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: monarchy
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Exelord
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-04-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: activerecord
         | 
| @@ -30,14 +30,14 @@ dependencies: | |
| 30 30 | 
             
                requirements:
         | 
| 31 31 | 
             
                - - '='
         | 
| 32 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            -
                    version: 6. | 
| 33 | 
            +
                    version: 6.5.0
         | 
| 34 34 | 
             
              type: :runtime
         | 
| 35 35 | 
             
              prerelease: false
         | 
| 36 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 37 | 
             
                requirements:
         | 
| 38 38 | 
             
                - - '='
         | 
| 39 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            -
                    version: 6. | 
| 40 | 
            +
                    version: 6.5.0
         | 
| 41 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 42 | 
             
              name: configurations
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -124,7 +124,7 @@ dependencies: | |
| 124 124 | 
             
                    version: 3.5.0
         | 
| 125 125 | 
             
            description: Hierarchical access management system with roles inheritance.
         | 
| 126 126 | 
             
            email:
         | 
| 127 | 
            -
            -  | 
| 127 | 
            +
            - exelord@macsour.com
         | 
| 128 128 | 
             
            executables: []
         | 
| 129 129 | 
             
            extensions: []
         | 
| 130 130 | 
             
            extra_rdoc_files: []
         |