Dry::Types::Struct.constructor_type
is the Virtus
of dry-types
dry-initializer
is waiting for release, but I'm not sure whether to publish it from my account, or somehow else
dry-function
. Its scope was to replace virtus by something more efficient and safe.
dry-types
, but allows simple PORO types as well
dry-types
should be core thing and dry-initializer to work on top of it
dry-initializer
does is... well... initialization ;)dry-initializer
is about extraction of options
from rom-support
default: -> { ... }
syntax only
0.0.1
before
default
option should be dropped IMO and you should just define a type with default value, like in dry-types structs
:writer
option
param
and option
are fantastic, I can use exactly this in many many places
attr_hash
is also too much for me, and it creates confusion that these type of objects are hash mappers at the same time
I'm agree about attr_hash
, and will remove it today. Concerning defaults, I feel I have to know more about dry-types
. I'll reed it and make a decision.
Still not sure about reader
and writer
. From the one hand, I'm agree - initializer is a separate feature. But from the other, I look at the initializer as an instance dependency injector, and would prefer those dependencies to be readable. Maybe it makes sense to keep reader
and drop writer
writer
is awful ;)
Types::String.default(“foo”)
Hi everyone, I'm unclear on the difference between Dry::Types::Struct and Dry::Types::Value -- what features does one have that the other doesn't? The documentation is clear on their similarity but not their differences!
You can define value objects which will behave like structs and have equality methods too
schema
syntax won’t work with “models”
schema
applies hash?
predicate automatically
attr
DSL instead of key
attr
DSL, it should work
attr(:foo).model { … }
schema.call
with a hash (with nested hash). Not sure to understand the problem
type
is not a hash
to_hash
method that creates a hash (with nested hashes) to feed the call
method
Entity.new
only uses strings and a hash.
#<#<Class:0x007fa07a81cbb8>:0x007fa07a8a5b98 @rule_compiler=#….
this is so awful, I gotta do something about that
binding.pry
in the custom predicates I defined.for example:
require 'dry/validation'
require 'pry'
SCHEMA = Dry::Validation.Schema do
binding.pry
end
also doing some puts in there or smth else never executes, so I doubt that the block is actually ever executed? :D
test.rb:5:in `block in <main>': undefined method `pry' for #<Dry::Validation::Schema::Rule:0x0056432b6dd048> (NoMethodError)
from /home/benny/Dev/onlim/adapter/.gem/ruby/2.3.0/gems/dry-validation-0.7.3/lib/dry/validation.rb:23:in `instance_exec'
from /home/benny/Dev/onlim/adapter/.gem/ruby/2.3.0/gems/dry-validation-0.7.3/lib/dry/validation.rb:23:in `Schema'
from test.rb:4:in `<main>'
shell returned 1
require 'dry/validation'
require 'pry'
SCHEMA = Dry::Validation.Schema do
puts 'hi'
end
::Kernel.byebug
Kernel.puts 'hi'
works, thx for that hint :D
sooo I just wrote this in a Struct class:
# Hack to make things writable with type checking
def self.attributes(new_schema)
super
new_schema.keys.each do |k|
define_method("#{k}=") do |value|
instance_variable_set("@#{k}", self.class.schema[k][value])
end
end
end
:scream:
Dry::Types::Struct
as opposed to done automatically for me by something like Active Record
UnknownAttributeError :foo
instead of undefined method 'foo'
I'm less likely to spend time tracking down what went wrong because the error is more clearbe middleman deploy
middleman deploy
be middleman build
locally too
be middleman
and visit the server