rails_ops 1.0.0.beta3 → 1.0.0.beta4
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/README.md +20 -11
- data/VERSION +1 -1
- data/lib/rails_ops/controller_mixin.rb +11 -0
- data/lib/rails_ops/mixins/model/nesting.rb +8 -4
- data/rails_ops.gemspec +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 200bc5c12a821e07b6d10cfd18d1349c3005a1b3
|
4
|
+
data.tar.gz: 7dbf7c447bb0a472e28583ea0dc69d4f89ca185a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 488428cdb605dd24250003a2d917200f46c86eab3906777489efcb19bca117c7e028a76412042e5a43f261c03c47726cd9780ba83f66ff2a2c92d2908e2e9f30
|
7
|
+
data.tar.gz: 417abae7e58449757d96885f22ab2ab92b70bb5ad08a27523d55c320e3f8b869ecba128f929a06bb431ca1ef5a5c963e3e8f2e16831733066359a3d949a90bd0
|
data/README.md
CHANGED
@@ -7,9 +7,9 @@ rails_ops
|
|
7
7
|
|
8
8
|
This Gem introduces an additional service layer for Rails: *Operations*. An
|
9
9
|
operation is in most cases a *business action* or *use case* and may or may not
|
10
|
-
involve one or multiple models. Rails Ops
|
11
|
-
applications by splitting them up into
|
12
|
-
is specified in a single, testable class.
|
10
|
+
involve one or multiple models. Rails Ops allows creating more modular
|
11
|
+
applications by splitting them up into their different operations. Each
|
12
|
+
operation is specified in a single, testable class.
|
13
13
|
|
14
14
|
To achieve this goal, this Gem provides the following building blocks:
|
15
15
|
|
@@ -23,13 +23,13 @@ Operation Basics
|
|
23
23
|
|
24
24
|
### Placing and naming operations
|
25
25
|
|
26
|
-
- Operations generally reside in `app/operations` and can be nested using
|
27
|
-
subdirectories. They're all inside of the `Operations` namespace.
|
26
|
+
- Operations generally reside in `app/operations` and can be nested using
|
27
|
+
various subdirectories. They're all inside of the `Operations` namespace.
|
28
28
|
|
29
29
|
- Operations operating on a specific model should generally be namespaced with
|
30
30
|
the model's class name. So for instance, the operation `Create` for the `User`
|
31
|
-
model should generally live under `app/operations/user/create.rb` and
|
32
|
-
be called `Operations::User::Create`.
|
31
|
+
model should generally live under `app/operations/user/create.rb` and
|
32
|
+
therefore should be called `Operations::User::Create`.
|
33
33
|
|
34
34
|
- Operations inheriting from other operations should generally be nested within
|
35
35
|
their parent operation. See the next section for more details.
|
@@ -51,8 +51,8 @@ When declaring an operation within a namespace,
|
|
51
51
|
- Determine whether the namespace you're using is a module or a class. Make sure
|
52
52
|
you don't accidentally redefine a module as a class or vice-versa.
|
53
53
|
|
54
|
-
- If the operation resides within a module, make a module definition on the
|
55
|
-
line and the operation class on the second. Example:
|
54
|
+
- If the operation resides within a module, make a module definition on the
|
55
|
+
first line and the operation class on the second. Example:
|
56
56
|
|
57
57
|
```ruby
|
58
58
|
module Operations::Frontend::Navigation
|
@@ -958,7 +958,7 @@ source code for implementation details.
|
|
958
958
|
## Model authorization
|
959
959
|
|
960
960
|
While you can use the standard `authorize!` method (see chapter *Authorization*)
|
961
|
-
for authorizing models, RailsOps provides
|
961
|
+
for authorizing models, RailsOps provides a more convenient integration.
|
962
962
|
|
963
963
|
### Basic authorization
|
964
964
|
|
@@ -966,7 +966,7 @@ Model authorization can be performed via the operation instance methods
|
|
966
966
|
`authorize_model!` and `authorize_model_with_authorize_only!` (see chapter
|
967
967
|
*Authorization* for more information on the difference between these two).
|
968
968
|
|
969
|
-
|
969
|
+
These two methods provide a simple wrapper around `authorize!` and
|
970
970
|
`authorize_only!` that casts the given model class or instance to an active
|
971
971
|
record object. This is necessary if the given model class or instance is a
|
972
972
|
(possibly anonymous) extension of an active record class for certain
|
@@ -1213,6 +1213,15 @@ while more specific operations can use `:update` or whatever. If we really need
|
|
1213
1213
|
to check for `:read` when updating an object, it can be implemented in the
|
1214
1214
|
ability class.
|
1215
1215
|
|
1216
|
+
## Change log
|
1217
|
+
|
1218
|
+
### 1.0.0.beta4
|
1219
|
+
|
1220
|
+
* Fix a bug where nested models are saved at build time in update operations in
|
1221
|
+
some cases.
|
1222
|
+
|
1223
|
+
* Start of change log.
|
1224
|
+
|
1216
1225
|
## Copyright
|
1217
1226
|
|
1218
1227
|
Copyright (c) 2017 Sitrox. See `LICENSE` for further details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.0.
|
1
|
+
1.0.0.beta4
|
@@ -34,6 +34,7 @@ module RailsOps
|
|
34
34
|
return @op
|
35
35
|
end
|
36
36
|
|
37
|
+
# Determines whether an operation has been set.
|
37
38
|
def op?
|
38
39
|
!!@op
|
39
40
|
end
|
@@ -65,20 +66,30 @@ module RailsOps
|
|
65
66
|
return success
|
66
67
|
end
|
67
68
|
|
69
|
+
# Returns the current operation's `model`. Fails with an exception if the
|
70
|
+
# current operation does not respond to the `model` (i.e. is not a model
|
71
|
+
# operation).
|
68
72
|
def model
|
69
73
|
return @model if @model
|
70
74
|
fail 'Current operation does not support `model` method.' unless op.respond_to?(:model)
|
71
75
|
return op.model
|
72
76
|
end
|
73
77
|
|
78
|
+
# Filters the `params` hash for use with RailsOps. This removes certain
|
79
|
+
# web-specific parameters based on `EXCEPT_PARAMS`.
|
74
80
|
def filter_op_params(params)
|
75
81
|
(params || {}).except(*EXCEPT_PARAMS)
|
76
82
|
end
|
77
83
|
|
84
|
+
# Filters operation params using `filter_op_params`, permits them using
|
85
|
+
# strong params and converts them to a hash. This method can be overridden
|
86
|
+
# for passing custom params to an operation for an entire controller.
|
78
87
|
def op_params
|
79
88
|
filter_op_params(params.permit!).to_h
|
80
89
|
end
|
81
90
|
|
91
|
+
# Constructs and returns the operation context used for instantiating
|
92
|
+
# operations from within this controller.
|
82
93
|
def op_context
|
83
94
|
@op_context ||= begin
|
84
95
|
context = RailsOps::Context.new
|
@@ -137,14 +137,18 @@ module RailsOps::Mixins::Model::Nesting
|
|
137
137
|
# Instantiate nested operation
|
138
138
|
@nested_model_ops[attribute] = sub_op(config[:klass], wrapped_params)
|
139
139
|
|
140
|
-
# Inject model of nested operation to our own model
|
140
|
+
# Inject model of nested operation to our own model. We directly set the
|
141
|
+
# association's target instead of using the standard setter method as the
|
142
|
+
# latter one can save the models in some occasions.
|
141
143
|
nested_model = @nested_model_ops[attribute].model
|
142
|
-
model.
|
144
|
+
model.association(attribute).target = nested_model
|
143
145
|
|
144
146
|
# Inject our own model to model of nested operation (if the inverse
|
145
|
-
# reflection can be resolved)
|
147
|
+
# reflection can be resolved). We directly set the association's target
|
148
|
+
# instead of using the standard setter method as the latter one can save
|
149
|
+
# the models in some occasions.
|
146
150
|
if (inverse_reflection = model.class.reflect_on_association(attribute).inverse_of)
|
147
|
-
nested_model.
|
151
|
+
nested_model.association(inverse_reflection.name).target = model
|
148
152
|
end
|
149
153
|
end
|
150
154
|
end
|
data/rails_ops.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: rails_ops 1.0.0.
|
2
|
+
# stub: rails_ops 1.0.0.beta4 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rails_ops".freeze
|
6
|
-
s.version = "1.0.0.
|
6
|
+
s.version = "1.0.0.beta4"
|
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-
|
11
|
+
s.date = "2017-11-16"
|
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/protected_attributes.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/test_helper.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.
|
4
|
+
version: 1.0.0.beta4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -245,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
245
|
version: 1.3.1
|
246
246
|
requirements: []
|
247
247
|
rubyforge_project:
|
248
|
-
rubygems_version: 2.6.
|
248
|
+
rubygems_version: 2.6.14
|
249
249
|
signing_key:
|
250
250
|
specification_version: 4
|
251
251
|
summary: An operations service layer for rails projects.
|