Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 07 14:03

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 10:01
    Travis dry-rb/dry-view (master) errored (636)
  • Dec 07 09:58
    Travis dry-rb/dry-view (master) errored (635)
  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:56

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 07 09:54

    dry-bot on master

    [devtools] config sync (compare)

Alexander
@cutalion
I remember I looked at berg app and was trying to build my own app. So, I do not remember why I require api after finalize! :smile:
app/api here defines grape application.
Can somebody else share config for dry-system/dry-web application too? Would be interesting to compare
Tim Riley
@timriley
@cutalion don’t load the boot file in tests
@cutalion just require the container directly: require “my_app/container”, this will leave it un-finalized and allow you to add the stubs support
Steve Clarke
@srcnix
Is there anyway in Dry System Container to load all files in a specific directory as bootable? Or is it a simple case of that's how much app works so down to me? Just wondering what conventions are already built in.
Piotr Solnica
@solnic
@srcnix bootable components are registered via Container.boot method
by convention, we store them under {system_dir}/boot/*.rb
Steve Clarke
@srcnix
Thanks @solnic
Mateusz Kluge
@inclooder
Hello, Is it possible to set default value for key in dry-validation ? For example optional(:enabled).maybe(:bool?) to be false by default?
Lairan
@alex-lairan

You can use http://dry-rb.org/gems/dry-validation/input-preprocessing/

optional(:enabled, FalseBoolean).maybe(:bool?)

Mateusz Kluge
@inclooder
How would you define FalseBolean ? Dry::Types.module::Bool.default(false) or Dry::Types.module::Strict::Bool.default(false) ?
Does it matter ?
Lairan
@alex-lairan

I don't know, sorry :s

An example of what i've done:

module Types
  include Dry::Types.module

  Checkbox = Types::Bool.constructor do |str|
    str == '1' || str == true || str == 'true'
  end
end
I think you can do something like
FalseBolean = Types::Bool.constructor do |value|
  value || false
end
Mateusz Kluge
@inclooder
Thank you @alex-lairan I'll check if that solves my problem. Have a good day :+1:
Lairan
@alex-lairan
:+1:
Ivan Shamatov
@IvanShamatov
Hello there
I’m looking at dry-view for quite a while now and it sounds rediculus to have templateless-view, right?
though i found it really useful to operate like serializer
maybe I’m missing something again, are there any consideration on that question?
Tim Riley
@timriley
@IvanShamatov dry-view still uses templates
Spencer Goh
@dymaxionuk
Anyone here use dry-web-roda / dry-rb + IntelliJ. I find the IDE gets really confused (syntax/error highlighting), because of the dynamic lookups the framework gives (ioc, module factories etc). Have you found anyway of making IntelliJ less confused?
Erik Jenks
@erikjenks
Question for those of you who use Dry::Validation. I am currently attempting to generate some API documentation and I am using Dry::Validation for input. Is there a way to parse a Schema to view acceptable parameters and values?
Oskar Szrajer
@gotar
Hi, any easy way to extend Dry-system based app (dry-web) with own acronym (dry-inflector). I know Dry-system use dry-loader and it is initialized with Inflector instance - and I can overwrite loader. But maybe there is easier way just to extend those inflector instance somehow?
@flash-gordon ^?
ps thx for extending dry-inflector (acronyms) ;]
Nikita Shilnikov
@flash-gordon
@gotar I would go with a custom loader for now, but I think we could have it as a standalone config option that is passed to the loader
I actually have the same problem but didn't have a chance to set up my app with the new inflector
I'll do it before a new relaese, I hope soon
Oskar Szrajer
@gotar
ok thx for info :) Yes some custom config will be nice, something like custom boot script for inflector, registered inside container, and then passed as a config option for dry-system
sound good
Jonah
@jonahx
best practice question, not specifically related to the dry gems but input from regulars here would be appreciated. say you have a class that raises specific domain errors, related to that class. Do you:
  1. Define the custom error classes inside the domain class and access them like MyClass::MyError?
  2. Define the custome error classes in the same file as the domain class but outside of it, so client code can directly access MyError?
  3. Something else?
Andy Holland
@AMHOL
I'd namespace it, MyClass::MyError
Jonah
@jonahx

I want a type to represent a non empty string, is there a builtin for this or should I just do:

NonEmptyString = Types::Strict::String.constrained(
  format: /\S+/
)

?

Nikita Shilnikov
@flash-gordon
there's no predefined type for this
Daniel Sandbecker
@daniels

In Dry::Validation, is there a way to define a custom error message for a rule block, that isn't composed of messages from the individual predicates used in the block? I have a form where I want to enforce a checkbox only if the birthdate given in another field is for a person under 18:

rule(acknowledge_age_if_young: [:acknowledge_age, :birth_date]) do |acknowledge_age, birth_date|
  birth_date.older?(18) | acknowledge_age.true?
end

But the automatic error message is a join of the older?-message and the true?-message, with " or " as the delimiter: "must be older than 18 or must be true". I can customize each of these messages, but I don't see how/if I can use a message without an " or ". Basically I just wan't to say "You need to check this box if you're not 18".

Daniel Sandbecker
@daniels
Ok, after searching and testing for hours I found an answer in the forum right after I posted here: https://discourse.dry-rb.org/t/difficulty-creating-error-messages-for-high-level-rules/238/2
Jonah
@jonahx

Could someone clarify for me the purpose of Types.Constructor:

user_type = Types.Constructor(User)

# It is equivalent to User.new(name: 'John')
user_type[name: 'John’]

What is the differentce between User and user_type — other than that you can construct with []rather than new? Types.Instance makes sense to me, since we’re checking that the value passed is an instance of a certain class. But what are we checking with a constructor type?

Piotr Solnica
@solnic
@jonahx just a shortcut for Types::Definition.new(User).constructor(&User.method(:new))
Jonah
@jonahx
@solnic what is the typical use case for this kind of type?
Piotr Solnica
@solnic
@jonahx ie type annotation in dry/rom structs
in general, dry-types provide type definitions (as in, they define the primitive class), with optional constructors, constraints and arbitrary meta-information, there are tons of use cases for them
Jonah
@jonahx
@solnic thanks, yeah, i knew that part. i use and love Dry::Struct. By use case I meant, an example of a dry struct that would need an attribute with a contructor type. I’m having trouble connecting the idea to something that would come up in my work.
Jonah
@jonahx

separate question: Is there a better (more concise) way to achieve the equivalent of the following using dry::struct or dry::types:

class Webservices
  include Enumerable
  extend Forwardable

  TYPE = Types.Array(Types.Instance(Webservice))

  def initialize(arr)
    @arr = TYPE[arr]
  end
  def_delegators :@arr, :each
end

Note: I want to be able to construct using a single, unnamed parameter as in Webservices.new([service1, service2]).
Essentially, I want a typed array constructible using Webservices.new.

Pavel Argentov
@argent-smith
Hi ppl. How to package a Klass::ActiveRecord_Associations_CollectionProxy into a dry-struct (via dry-types)?
Specifically, I want to declare a certain model's scope as a struct member
Nikita Shilnikov
@flash-gordon
@argent-smith you can use Types::Any in comlex cases
Pavel Argentov
@argent-smith
thnx
I've tried Types.Definition() as well: it works