timriley on rich-component-dirs-config
Add component_dirs setting Rem… Scan component file for magic c… Make load_component easier to u… (compare)
timriley on rich-component-dirs-config
Fix wording Add Rubocop rule Clarify names Fixup naming and 4 more (compare)
flash-gordon on master
Add more predicates to mapping (compare)
timriley on rich-component-dirs-config
Use base Dry::Container missing… (compare)
timriley on rich-component-dirs-config
Make load_component easier to u… (compare)
dry-bot on master
[devtools] sync (compare)
flash-gordon on master
Make predicate inference truly … Update changelog.yml (compare)
flash-gordon on custom-builder-methods
Support for custom builder meth… (compare)
flash-gordon on or_nil-extension
Add Type#or_nil via builders ex… (compare)
dry-bot on master
[devtools] sync (compare)
flash-gordon on master
Fix changelog (compare)
dry-bot on master
[devtools] sync (compare)
Range#include?
should work I think?
predicate(:included_in?) do |list, input|
list.include?(input)
end
predicate(:includes?) do |value, input|
input.include?(value)
end
input_value.included_in?(list)
vs input_value.includes?(value)
One more thing provided by @marshall-lee for initializer in our commercial project is the ar_param
or ar_option
.
It allows to set object dependency as either model or model id.
In Rails projects this proves to be very suitable (example below is over-simplified):
class DestroyUser
ar_param :user
def call
user.destroy
end
def self.call(*args)
new(*args).call
end
end
user_id = 1
user = User.find 1
# This methods are the same
DestroyUser.call user_id
DestroyUser.call user
Under the hood the method either gets an activerecord instance or finds its by id (or by another argument):
ar_param :user, find_by: :key
The question is what do you think about implementing this behaviour in a submodule of dry-initializer
(dry-initializer/rails
)?
[17] pry(main)> LocalSearch::Types::Form::Bool['1']
=> true
[18] pry(main)> LocalSearch::Types::Form::Bool['0']
=> false
[19] pry(main)> LocalSearch::Types::Form::Bool['false']
=> false
[20] pry(main)> LocalSearch::Types::Form::Bool['False']
=> "False"