These are chat archives for dry-rb/chat

17th
Jan 2017
Jan Stevens
@JanStevens
Jan 17 2017 09:47
Basically I need the good old virtus where you can define a module and then later on include it in your instance when needed. Is the same possible in DRY world? :D
Piotr Solnica
@solnic
Jan 17 2017 09:48
@JanStevens yes, as I mentioned, just define a module with included hook and class-eval
Jan Stevens
@JanStevens
Jan 17 2017 09:48
@solnic small tiny example? :D
Tim Riley
@timriley
Jan 17 2017 09:49
module MyThing
  def self.included(base)
    base.class_eval do
      attribute :foo, Types::Strict::String
    end
  end
end
Piotr Solnica
@solnic
Jan 17 2017 09:49
module MyAttrs
  def self.included(klass)
    klass.class_eval do
        # aaand Tim was faster
  end
end
Tim Riley
@timriley
Jan 17 2017 09:49
haha
Jan Stevens
@JanStevens
Jan 17 2017 09:49
Haaaa I see
Oke really thanks alot :)
Tim Riley
@timriley
Jan 17 2017 09:49
fairly common ruby pattern
@solnic sorry :kissing_heart:
Piotr Solnica
@solnic
Jan 17 2017 09:49
@timriley :D
Tim Riley
@timriley
Jan 17 2017 09:51
@solnic btw, I’m gonna work on dry-rb/dry-view#15 tonight, but it’ll be easiest done based on top of my work in dry-rb/dry-view#25, so if you have any reservations, let me know and I can hold off.
Piotr Solnica
@solnic
Jan 17 2017 09:56
@timriley I don’t, if it works better for you then go for it
Tim Riley
@timriley
Jan 17 2017 09:56
Thanks @solnic :)
dry-view 0.2.0 is going to be a big release
Piotr Solnica
@solnic
Jan 17 2017 09:56
I don’t like conditionals in templates but enforcing that seems to be an overkill, esp in the early days of a project, so I’m not surprised it didn’t work well for you
Tim Riley
@timriley
Jan 17 2017 09:57
yeah, I know what you mean. I think if you did want to avoid them, it is something that you can build extra tooling around on top of a less opinionated base
i.e. dry-view with #25 applied would hoefully not stop people from being stricter
Jan Stevens
@JanStevens
Jan 17 2017 09:59
Can I also define an attribute lazy on an instance? The class_eval works but that changes my definition of my class obviously (Don’t really want that)
Tim Riley
@timriley
Jan 17 2017 10:09
@JanStevens why do you want to do that?
Jan Stevens
@JanStevens
Jan 17 2017 10:09
@timriley yea it makes no sense at all,
Trying to duck type in the same class
Ahmad A.Elghany
@ahmgeek
Jan 17 2017 23:46

hey folks, sorry to bother

  class Traces < ROM::Relation[:sql]
    schema(:traces) do
      attribute :id, Types::Serial
      attribute :trace, Types::JSONB
    end
end

that doesnt seem to work for the Jsonb in postgres
I've tried https://github.com/rom-rb/rom-sql/blob/master/lib/rom/sql/extensions/postgres/types.rb#L39-L58 most of these but no way.

any hints