Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Krzysztof Wawer
@wafcio
and I found that when call method is invoked then finalizers hash is empty
I mean not empty but container and finalizer variables are nil
Krzysztof Wawer
@wafcio
ok I found what is going on, maybe it is bug, maybe it isn't:
my finalizers (persistence.rb) look like this:
ComicsScraper.namespace(:persistence) do |persistence|
  persistence.finalize(:rom) do
    init do
    end

    start do
    end
  end
end
finalizers hash contains this value: {:rom=>[ComicsScraper, #<Proc:0x007f9cb4205870@/Users/wafcio/projects/comics/scraper/system/boot/persistence.rb:2>]}
but call method is invoked with :persistence argument, so it looks :persistence key in finalizers hash.
probably I should call file rom.rb like name in finalize method, and problem will not appear, but in my opinion it is bug
Andy Holland
@AMHOL
Oh, wait
ComicsScraper.namespace => ComicsScraper.finalize
Krzysztof Wawer
@wafcio
ComicsScraper.finalize! I run it
Andy Holland
@AMHOL

Yeah but this:

ComicsScraper.namespace(:persistence) do |persistence|
  persistence.finalize(:rom) do
    init do
    end

    start do
    end
  end
end

Should be:

ComicsScraper.finalize(:persistence) do |container|
  container.register(:rom) do
    init do
    end

    start do
    end
  end
end
Sorry, updated
I think anyway
Krzysztof Wawer
@wafcio
let me check
Andy Holland
@AMHOL
Or container.register should be called in the init block
# system/boot/db.rb

Application.finalize(:db) do |container|
  init do
    require 'some/3rd/party/db'

    container.register(:db, DB.configure(ENV['DB_URL']))
  end

  start do
    db.establish_connection
  end

  stop do
    db.close_connection
  end
end
Krzysztof Wawer
@wafcio
without namespace it works
Andy Holland
@AMHOL
Ahh OK, yeah, the idea there is that you add a bootable :rom component, but that registers persistence.rom in the container
Whereas you're trying to boot the namespace
Krzysztof Wawer
@wafcio
thanks for help
Andy Holland
@AMHOL
NP
Krzysztof Wawer
@wafcio
I am creating console ruby app with dry-system and some features are missing, which exist in dry-web. dry-web shouldn't be small wrapper with rack, monitoring stuff, which easly allow to create web app ? Am I correct or not ?
Pablo Herrero
@pabloh
Where can you find some documentation about defining custom types with coercion to use with dry-validation?
Don Morrison
@elskwid
@pabloh I went looking for this the other day and ended up digging around in rom-sql since there are custom types built for postgres (for example)
Andy Holland
@AMHOL
@wafcio if it's useful for a console app then it should probably be in dry-system
Krzysztof Wawer
@wafcio
@AMHOL should I create new topic about it on forum ?
Piotr Solnica
@solnic
Just report an issue
John Backus
@backus
@solnic thoughts on adding something like Dry::Types::Type which all type definitions inherit from? Seems like it would make dry types a bit easier to work with if all type definitions === Dry::Types::Type
blob
Not exactly true right now
(would also make the docs simpler :laughing: I'm currently trying to improve them even though they are already quite thorough)
Tim Riley
@timriley
@AMHOL Do you reckon you might be able to start a CHANGELOG.md for dry-configurable? :pray: :angel:
Oskar Szrajer
@gotar
hmm what happens with dry-fixtures? I was sure it was added some time ago to dry family , but cannot find it anywhere.
Tim Riley
@timriley
@gotar I don't think we had it. You might be interested in rom-factory though
Oskar Szrajer
@gotar
ah yes my mistake, I was searching for rom-factory ;]
thx
Andy Holland
@AMHOL
@timriley sure
Pablo Herrero
@pabloh
Is there an easy way to customize how dates and date_time attributes ares parsed from strings by the forms?
Nikita Shilnikov
@flash-gordon
@pabloh you can build a custom type for that. Time.constructor { ... }
Pablo Herrero
@pabloh
@flash-gordon, and then you can just use it like this?:
CustomType = Time.constructor { ... }

Dry::Validation.Form do
  required(:date).filled(type?: CustomType)
end
Nikita Shilnikov
@flash-gordon
@pabloh I'm not sure if type? will work, there are some issues with using custom types IIRC
    to_time = -> x { Time.iso8601("#{x}Z") }
    ISOTime = Types::Strict::Time.constructor(to_time)

    Schema = Dry::Validation.JSON do
      optional(:sent_at, :time).value(ISOTime)
...
that's what I have^
Pablo Herrero
@pabloh
@flash-gordon , why do you need the second argument at optional?
can you not just do optional(:sent_at) { time? | value(ISOTime) }?
Nikita Shilnikov
@flash-gordon
@pabloh the second argument is for type_specs, i.e. specifies value type, as far as I know dry-v atm can work without it, but slower
just test^ I dunno, not an expert here lol