rails_ops 1.0.0.beta7 → 1.0.0.beta8

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
- SHA1:
3
- metadata.gz: 011b8da5d8b7bc598a885694eadcaa3f248518f2
4
- data.tar.gz: 57d7ef1ec35e5dbb81ca990700f19f1f8feed9da
2
+ SHA256:
3
+ metadata.gz: 54e89e111239e2e4cde9619150a98e5bcd5649dc0168c3e36b2880aebb31bdf6
4
+ data.tar.gz: 1b10735d02b9ce98c45a15c21b5acf7b10b1a2ed4fc8fef07596e016a088c2cb
5
5
  SHA512:
6
- metadata.gz: 8dd34957e37e7ffd782bcd825f1373bf41ebf0149a20366a7da48cd8414549fa4579ae461accfffadcde77105c863018fba7e40cfb66fdd09d6e6396c7d9b0d7
7
- data.tar.gz: 8fb8b269aa8c5ee3222db5dd3d131f52b6866b6b3d1ec21a53109898c16d4c4796713ccff575b6217c93ace34f47ba3b7cfa79808835b63d696b0770746bbc4a
6
+ metadata.gz: 8762d1a7adbccdf779591132328a1a918e3beba62e130530a44cd46d8b4dcc39b20f3a8ba43d3d07225500e4a9a0fbf08ac20e1d887eaec667be38d0ed2689af
7
+ data.tar.gz: de07d7c6827d446b0d4838b775ef2abd5a1d6dacfc05075e0f30fcafaccfb7246cae4e04b0e6377ab85d908b90486adb6afa6f3ecbc16da09228ffd5de986ac6
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Sitrox
3
+ Copyright (c) 2018 Sitrox
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -211,7 +211,8 @@ Params Handling
211
211
 
212
212
  Each single operation can take a `params` hash. Note that it does not have to be
213
213
  in any relation with `ActionController`'s params - it's just a plain ruby hash
214
- called `params`.
214
+ called `params` (in fact, it is a `Object::HashWithIndifferentAcces`, more on
215
+ that later).
215
216
 
216
217
  Params are assigned to the operation via their constructor:
217
218
 
@@ -922,7 +923,7 @@ This behavior can also be overwritten per operation using the
922
923
 
923
924
  ```ruby
924
925
  class Operations::User::Load < RailsOps::Operation::Model::Load
925
- model User
926
+ model ::User
926
927
  lock_model_at_build false # Takes `true` if no argument is passed
927
928
  end
928
929
  ```
@@ -941,9 +942,36 @@ that.
941
942
 
942
943
  The `perform` method saves the record using `save!`.
943
944
 
945
+ ```ruby
946
+ class Operations::User::Create < RailsOps::Operation::Model::Create
947
+ schema do
948
+ req :user do
949
+ opt :first_name
950
+ opt :last_name
951
+ end
952
+ end
953
+
954
+ model User
955
+ end
956
+ ```
957
+
944
958
  As this base class is very minimalistic, it is recommended to fully read and
945
959
  comprehend its source code.
946
960
 
961
+ #### Overriding the perform method
962
+
963
+ While in many cases there is no need for overriding the `perform` method, this
964
+ can be useful i.e. when assigning or altering properties manually:
965
+
966
+
967
+ ```ruby
968
+ def perform
969
+ model.some_value = 42
970
+ model.first_name.upcase!
971
+ super # Saves the record
972
+ end
973
+ ```
974
+
947
975
  ### Updating models
948
976
 
949
977
  For creating models, you can use the base class
@@ -959,9 +987,26 @@ that.
959
987
 
960
988
  The `perform` method saves the record using `save!`.
961
989
 
990
+ ```ruby
991
+ class Operations::User::Update < RailsOps::Operation::Model::Update
992
+ schema do
993
+ req :id
994
+ req :user do
995
+ opt :first_name
996
+ opt :last_name
997
+ end
998
+ end
999
+
1000
+ model ::User
1001
+ end
1002
+ ```
1003
+
962
1004
  As this base class is very minimalistic, it is recommended to fully read and
963
1005
  comprehend its source code.
964
1006
 
1007
+ As with `Create` operations, the `perform` method can be overwritten at your
1008
+ liking.
1009
+
965
1010
  ### Destroying models
966
1011
 
967
1012
  For destroying models, you can use the base class
@@ -971,6 +1016,16 @@ class.
971
1016
  This class mainly provides an implementation of the method `perform`, which
972
1017
  destroys the model using its `destroy!` method.
973
1018
 
1019
+ ```ruby
1020
+ class Operations::User::Destroy < RailsOps::Operation::Model::Destroy
1021
+ schema do
1022
+ req :id
1023
+ end
1024
+
1025
+ model ::User
1026
+ end
1027
+ ```
1028
+
974
1029
  As this base class is very minimalistic, it is recommended to fully read and
975
1030
  comprehend its source code.
976
1031
 
@@ -1290,6 +1345,11 @@ setting in production mode though.
1290
1345
  Change log
1291
1346
  ----------
1292
1347
 
1348
+ ### 1.0.0.beta8
1349
+
1350
+ * Make sure that original state is always restored after calling
1351
+ `RailsOps.without_authorization`, even in case of an exception.
1352
+
1293
1353
  ### 1.0.0.beta7
1294
1354
 
1295
1355
  * #2 Get rid of protected attributes functionality
@@ -1318,4 +1378,4 @@ Rails architecture.
1318
1378
 
1319
1379
  ## Copyright
1320
1380
 
1321
- Copyright (c) 2017 Sitrox. See `LICENSE` for further details.
1381
+ Copyright (c) 2018 Sitrox. See `LICENSE` for further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.beta7
1
+ 1.0.0.beta8
data/lib/rails_ops.rb CHANGED
@@ -35,8 +35,11 @@ module RailsOps
35
35
  def self.without_authorization(&_block)
36
36
  previous_value = Thread.current[AUTH_THREAD_STORAGE_KEY]
37
37
  Thread.current[AUTH_THREAD_STORAGE_KEY] = false
38
- yield
39
- Thread.current[AUTH_THREAD_STORAGE_KEY] = previous_value
38
+ begin
39
+ yield
40
+ ensure
41
+ Thread.current[AUTH_THREAD_STORAGE_KEY] = previous_value
42
+ end
40
43
  end
41
44
  end
42
45
 
data/rails_ops.gemspec CHANGED
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: rails_ops 1.0.0.beta7 ruby lib
2
+ # stub: rails_ops 1.0.0.beta8 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "rails_ops".freeze
6
- s.version = "1.0.0.beta7"
6
+ s.version = "1.0.0.beta8"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Sitrox".freeze]
11
- s.date = "2017-12-19"
11
+ s.date = "2018-05-15"
12
12
  s.files = [".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, ".travis.yml".freeze, "Gemfile".freeze, "LICENSE.txt".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "lib/rails_ops.rb".freeze, "lib/rails_ops/authorization_backend/abstract.rb".freeze, "lib/rails_ops/authorization_backend/can_can_can.rb".freeze, "lib/rails_ops/configuration.rb".freeze, "lib/rails_ops/context.rb".freeze, "lib/rails_ops/controller_mixin.rb".freeze, "lib/rails_ops/exceptions.rb".freeze, "lib/rails_ops/hooked_job.rb".freeze, "lib/rails_ops/hookup.rb".freeze, "lib/rails_ops/hookup/dsl.rb".freeze, "lib/rails_ops/hookup/dsl_validator.rb".freeze, "lib/rails_ops/hookup/hook.rb".freeze, "lib/rails_ops/log_subscriber.rb".freeze, "lib/rails_ops/mixins.rb".freeze, "lib/rails_ops/mixins/authorization.rb".freeze, "lib/rails_ops/mixins/log_settings.rb".freeze, "lib/rails_ops/mixins/model.rb".freeze, "lib/rails_ops/mixins/model/authorization.rb".freeze, "lib/rails_ops/mixins/model/nesting.rb".freeze, "lib/rails_ops/mixins/policies.rb".freeze, "lib/rails_ops/mixins/require_context.rb".freeze, "lib/rails_ops/mixins/routes.rb".freeze, "lib/rails_ops/mixins/schema_validation.rb".freeze, "lib/rails_ops/mixins/sub_ops.rb".freeze, "lib/rails_ops/model_casting.rb".freeze, "lib/rails_ops/model_mixins.rb".freeze, "lib/rails_ops/model_mixins/ar_extension.rb".freeze, "lib/rails_ops/model_mixins/parent_op.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes.rb".freeze, "lib/rails_ops/model_mixins/virtual_attributes/virtual_column_wrapper.rb".freeze, "lib/rails_ops/model_mixins/virtual_has_one.rb".freeze, "lib/rails_ops/operation.rb".freeze, "lib/rails_ops/operation/model.rb".freeze, "lib/rails_ops/operation/model/create.rb".freeze, "lib/rails_ops/operation/model/destroy.rb".freeze, "lib/rails_ops/operation/model/load.rb".freeze, "lib/rails_ops/operation/model/update.rb".freeze, "lib/rails_ops/patches/active_type_patch.rb".freeze, "lib/rails_ops/profiler.rb".freeze, "lib/rails_ops/profiler/node.rb".freeze, "lib/rails_ops/railtie.rb".freeze, "lib/rails_ops/scoped_env.rb".freeze, "lib/rails_ops/virtual_model.rb".freeze, "rails_ops.gemspec".freeze, "test/db/models.rb".freeze, "test/db/schema.rb".freeze, "test/dummy/Rakefile".freeze, "test/dummy/app/assets/config/manifest.js".freeze, "test/dummy/app/assets/images/.keep".freeze, "test/dummy/app/assets/javascripts/application.js".freeze, "test/dummy/app/assets/javascripts/cable.js".freeze, "test/dummy/app/assets/javascripts/channels/.keep".freeze, "test/dummy/app/assets/stylesheets/application.css".freeze, "test/dummy/app/channels/application_cable/channel.rb".freeze, "test/dummy/app/channels/application_cable/connection.rb".freeze, "test/dummy/app/controllers/application_controller.rb".freeze, "test/dummy/app/controllers/concerns/.keep".freeze, "test/dummy/app/helpers/application_helper.rb".freeze, "test/dummy/app/jobs/application_job.rb".freeze, "test/dummy/app/mailers/application_mailer.rb".freeze, "test/dummy/app/models/application_record.rb".freeze, "test/dummy/app/models/concerns/.keep".freeze, "test/dummy/app/models/group.rb".freeze, "test/dummy/app/views/layouts/application.html.erb".freeze, "test/dummy/app/views/layouts/mailer.html.erb".freeze, "test/dummy/app/views/layouts/mailer.text.erb".freeze, "test/dummy/bin/bundle".freeze, "test/dummy/bin/rails".freeze, "test/dummy/bin/rake".freeze, "test/dummy/bin/setup".freeze, "test/dummy/bin/update".freeze, "test/dummy/bin/yarn".freeze, "test/dummy/config.ru".freeze, "test/dummy/config/application.rb".freeze, "test/dummy/config/boot.rb".freeze, "test/dummy/config/cable.yml".freeze, "test/dummy/config/database.yml".freeze, "test/dummy/config/environment.rb".freeze, "test/dummy/config/environments/development.rb".freeze, "test/dummy/config/environments/production.rb".freeze, "test/dummy/config/environments/test.rb".freeze, "test/dummy/config/initializers/application_controller_renderer.rb".freeze, "test/dummy/config/initializers/assets.rb".freeze, "test/dummy/config/initializers/backtrace_silencers.rb".freeze, "test/dummy/config/initializers/cookies_serializer.rb".freeze, "test/dummy/config/initializers/filter_parameter_logging.rb".freeze, "test/dummy/config/initializers/inflections.rb".freeze, "test/dummy/config/initializers/mime_types.rb".freeze, "test/dummy/config/initializers/rails_ops.rb".freeze, "test/dummy/config/initializers/wrap_parameters.rb".freeze, "test/dummy/config/locales/en.yml".freeze, "test/dummy/config/puma.rb".freeze, "test/dummy/config/routes.rb".freeze, "test/dummy/config/secrets.yml".freeze, "test/dummy/config/spring.rb".freeze, "test/dummy/db/schema.rb".freeze, "test/dummy/lib/assets/.keep".freeze, "test/dummy/log/.keep".freeze, "test/dummy/package.json".freeze, "test/dummy/public/404.html".freeze, "test/dummy/public/422.html".freeze, "test/dummy/public/500.html".freeze, "test/dummy/public/apple-touch-icon-precomposed.png".freeze, "test/dummy/public/apple-touch-icon.png".freeze, "test/dummy/public/favicon.ico".freeze, "test/dummy/tmp/.keep".freeze, "test/test_helper.rb".freeze, "test/unit/rails_ops/operation/model/create_test.rb".freeze, "test/unit/rails_ops/operation/model/load_test.rb".freeze, "test/unit/rails_ops/operation/model/update_test.rb".freeze, "test/unit/rails_ops/operation/model_test.rb".freeze, "test/unit/rails_ops/operation_test.rb".freeze]
13
13
  s.rubygems_version = "2.6.6".freeze
14
14
  s.summary = "An operations service layer for rails projects.".freeze
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta7
4
+ version: 1.0.0.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sitrox
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-19 00:00:00.000000000 Z
11
+ date: 2018-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -283,7 +283,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
283
283
  version: 1.3.1
284
284
  requirements: []
285
285
  rubyforge_project:
286
- rubygems_version: 2.6.14
286
+ rubygems_version: 2.7.6
287
287
  signing_key:
288
288
  specification_version: 4
289
289
  summary: An operations service layer for rails projects.