Comments (6)
I definitely think the new proposed architecture is nicer.
Providing a way for the user to specify their own context class is going to make your library more extensible and powerful, and saves me as an end user from monkey patching your code anyway.
I also think context_attributes
is too awkward, and much prefer your newer syntax and making it explicit that you're declaring props on a context class that you're also declaring vs an automagical declared context.
I do prefer the sub-classed Context
naming convention you had before, for example:
MyInteractor::Context
vs MyInteractorContext
, but it's a minor thing.
from activeinteractor.
What if the default behavior is to create a class (current behavior), unless one with the appropriate naming convention already exists?
In that case the naming convention might even be overkill, and using the self.context_class
is the defacto way to do it.
from activeinteractor.
I think it would also be beneficial to allow for an interactor to define it's own context class to allow for classes that don't meet the expected naming convention.
class User < ActiveRecord::Base
end
class AuthenticateUser < ActiveInteractor::Base
self.context_class = User
end
from activeinteractor.
from activeinteractor.
@zacharyw so instead of falling back to a generic context class with no validations and no attribute methods you're suggesting the fallback would be the current behavior?
from activeinteractor.
@aaronmallen I think so. I do see the benefit of being able to set a custom context, but for a lot of simple base case scenarios it may be annoying to have to manually keep creating new classes.
from activeinteractor.
Related Issues (20)
- Add a State Object
- Add the Result Object
- Ensure interactors return the result object
- Deprecate ActiveInteractor::Context::Status
- 2.0.0 Cleanup
- Remove ActiveInteractor::Context::Status
- Deprecate ActiveInteractor::Context::Errors
- Remove ActiveInteractor::Context::Errors
- [Bug Report] Allow default attributes to propagate to sibling/child interactors
- Add 2.0 Deprecator
- RFC Interactor#perform Cycle HOT 5
- Clean up ActiveInteractor::Context::Attributes
- Exclude Specs from Rubocop
- Address Lint/NoReturnInBeginEndBlocks cop in version.rb
- [Question] What is the expected Rollback behavior with complex skip_rollback ? HOT 6
- Rails 6.1 changes how ActiveModels are deep_dup'ed HOT 2
- Fix the 1-1-stable build
- Rollback unreleased code
- [Question]
- [Bug Report] before_perform invoked before context is validated
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from activeinteractor.