These are chat archives for dry-rb/chat

5th
Nov 2016
Alfonso Perez
@alfonsoperez
Nov 05 2016 03:27
Hi there!
I got introduced to these gems by a coworker and they are actually making me love my daily work with Ruby!
I have been trying to implement new functionality with Structs and Types, but I am getting a uninitialized constant Types::MyType (NameError), any ideas?
Tim Riley
@timriley
Nov 05 2016 05:12
Can you show us how you defined MyType, @alfonsoperez?
Alfonso Perez
@alfonsoperez
Nov 05 2016 15:01
Sure!, thanks!, I created a new file under /engines/mymodel/lib (this is a rails project), /engines/mymodel/lib/types.rb
module MyModel::Types
  include Types.module # this is in /app/types/app.rb 
  ...
  AnswerOutcome = Types::Strict::String.enum('expired', 'verified', 'unverifiable', 'flag')
end
and in /app/types/arr.rb ...
Dry::Types.register_class(Question)

module Types
  include Dry::Types.module
end
one hint I guess is that it says Types::AnswerOutcome, where it should say MyModel::Types::AnswerOutcome
Alfonso Perez
@alfonsoperez
Nov 05 2016 15:14
(I am doing MyModel::Types::AnswerOutcome in another file and that's where it's failing)
Luca Guidi
@jodosha
Nov 05 2016 15:34
@wafcio @solnic yay! :sparkles: :clap: