These are chat archives for dry-rb/chat

3rd
Jul 2016
dan-klasson
@dan-klasson
Jul 03 2016 02:30
like Dry::Validation::Schema::DSL weights.keys or Dry::Validation::Schema::DSL.weights.keys? neither works. problem is that the weights method is in another block
Brendon Murphy
@bemurphy
Jul 03 2016 02:44
I was reading the berg code for education and saw something I'm curious about. I noticed sometimes that the container isn't used and things hard couple to a class. I have some guesses why but would appreciate explanation...
Tim Riley
@timriley
Jul 03 2016 02:44
That’s a value object, not a functional object, which is why we just create an instance.
its purpose is to hold data, not to perform an action
Brendon Murphy
@bemurphy
Jul 03 2016 02:45
ah, because it holds the state of the user, you wouldn't want to reuse
thanks for the explanation, that helps
Tim Riley
@timriley
Jul 03 2016 02:47
Yeah. In other words, it's not a "dependency"
because AccessToken doesn't hold any internal values, you can reuse over and over and get new values. no internal state on it
so you can reuse that as a dependency
Tim Riley
@timriley
Jul 03 2016 03:00
Yep.
Brendon Murphy
@bemurphy
Jul 03 2016 03:00
cool. thanks for the clarification, appreciated.
Tim Riley
@timriley
Jul 03 2016 11:53
Would anyone have any idea why the top works, but the bottom fails?
def temperature_for_cafe(cafe)
  Dry::Monads.Maybe(cafe).fmap(&:address).fmap(&:locality)
end


def temperature_for_cafe(cafe)
  Dry::Monads.Maybe(cafe)
    .fmap(&:address)
    .fmap(&:locality)
end
line 0: syntax error near unexpected token `&'
line 0: `fmap(&:address)'
ohh
maybe it’s a pry thing :(
Yes, it is.
Dmitriy Plekhanov
@onemanstartup
Jul 03 2016 14:25
Am I using dry-validation wrong?
/dry-validation-0.8.0/lib/dry/validation/input_processor_compiler.rb:66:in `visit_implication': wrong number of arguments (given 2, expected 1) (ArgumentError)
        configure do
          def unique?(value)
            NewsPost.find_by(title: value).nil?
          end
        end

        required(:title) { filled? & min_size?(9) > unique? }
Dmitriy Plekhanov
@onemanstartup
Jul 03 2016 14:48
ah my I need to use &. 🌴