-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor cable_car to eliminate duplication #3
Conversation
Hey Josh, I finally had a proper opportunity to go over this PR and it's really great. I have some questions and requests but I'm 100% going to merge this once it's sorted.
Thanks Josh! This makes the whole PR even more transformative. |
The method_missing in the operation module forwards calls to the underlying operation builder. Lets you use the operations directly on cable_car/channel. It's basically a generic way to delegate methods to the operation builder.
|
You rock, sir! I was very impressed with your implementation. |
…ctory # Conflicts: # lib/cable_ready/channel.rb
Nate's changes threw a wrench in the works, so I've made OperationBuilder a class that cable car and channel inherit. It's functionally the same as it was, except now cable_car has an identifier of "CableCar". I've added the custom renderer you were looking for as well. |
That's awesome, thank you very much. I'm sorry that the finalizer changes were more dramatic than I had realized. That's also precisely why I left it for you. When you say that "cable_car has an identifier of 'CableCar'", where does that come into play? What I'm really asking/picturing is that developers will |
Doesn't effect the developer, it's just for the finalizers. |
I'm pretty sure this would fix it: def broadcast(clear: true)
ActionCable.server.broadcast identifier, {"cableReady" => true, "operations" => operations_payload}
reset! if clear
end
def broadcast_to(model, clear: true)
identifier.broadcast_to model, {"cableReady" => true, "operations" => operations_payload}
reset! if clear
end |
@leastbad Thanks for the catch. Had trouble getting tests working for those methods due to not running in a rails context. We should really cover those if we can figure out how. |
750a0d7
to
eaea3a7
Compare
Just being honest, @marcoroth is about 850x more likely to know how to help with that. It's a major hole in my capability. Anyhow, thanks for helping to make cable_car and CableReady better! |
2 files added:
operation_builder
method that creates or returns a single instance of OperationBuilder. It forwards all missing methods to OperationBuilder should it respond to it, as well as implicitly returns self from missing methods (allowing method chaining).I also added tests!