Generally speaking, Rails core resists to change its fundamentally flawed architecture. Instead of adding new abstractions, such as form objects, they basically add conditional :if
everywhere as a work-around. This document discusses the solutions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'bundler/inline' | |
gemfile do | |
source 'https://rubygems.org' | |
gem 'trailblazer-operation' | |
end | |
# require "trailblazer-operation" | |
module Image | |
module Operation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "benchmark-ips" | |
require 'benchmark/ips' | |
# This is all about merging {config} or not. | |
# Never merge. Fastest. | |
def container_fast(activity, bla: "default") | |
{ | |
activity: activity, | |
bla: bla, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If you don't want to use :params because you want to post/patch a "real" document using the request body. | |
# test file: | |
patch "/api/v2/diagrams/1", headers: {"RAW_POST_DATA" => '{"my":"json doc"}'}, as: :json | |
# to read it in a controller action | |
def update | |
document = request.body.read |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "trailblazer-activity", github: "trailblazer/trailblazer-activity", branch: "ruby-3" | |
gem "trailblazer-activity-dsl-linear", github: "trailblazer/trailblazer-activity-dsl-linear", branch: "ruby-3" | |
gem "trailblazer-operation", github: "trailblazer/trailblazer-operation", branch: "ruby-3" | |
gem "trailblazer-macro", github: "trailblazer/trailblazer-macro", branch: "ruby-3" | |
gem "trailblazer-macro-contract", github: "trailblazer/trailblazer-macro-contract", branch: "ruby-3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem "dry-validation" | |
require "dry-types" | |
module Types | |
include Dry::Types.module | |
end | |
require 'dry/logic' | |
require 'dry/logic/predicates' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class KW | |
def self.call | |
# | |
# proc! | |
# or | |
# meth! | |
end | |
def self.meth! | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"color_scheme": "Packages/Color Scheme - Default/IDLE.tmTheme", | |
"save_on_focus_lost": true, | |
"trim_trailing_white_space_on_save": true, | |
"tab_size": 2, | |
"ensure_newline_at_eof_on_save": true, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module PipeOperators | |
def <(*args) | |
A.new(self, "<") | |
end | |
def |(*args) | |
A.new(self) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my_container = Dry::Container.new | |
my_container.register(:user_repository, -> { Object }) | |
AutoInject = Dry::AutoInject(my_container) | |
class Create < Trailblazer::Operation | |
include AutoInject[:user_repository] | |
end | |
Create.(params, {}) |
NewerOlder