« Back to channel list

#ruby - 29 January 2019

« Back 1 day Forward 1 day »
[00:05:22] mikecmpbll: has joined #ruby
[00:20:55] Swyper: has joined #ruby
[00:22:02] cnsvc: has joined #ruby
[00:23:02] catphish: has joined #ruby
[00:26:36] jottr: has joined #ruby
[00:30:19] keden: has joined #ruby
[00:33:06] Swyper: has joined #ruby
[00:48:15] catphish: https://github.com/ruby/ruby/blob/trunk/lib/cgi/cookie.rb#L118
[00:48:18] catphish: no it doesn't
[00:48:49] catphish: hm, actually it's an array, so i guess it does
[00:55:55] akem: has joined #ruby
[00:57:49] perique: has joined #ruby
[00:59:08] evdubs: has joined #ruby
[01:05:45] jottr: has joined #ruby
[01:13:23] nowhere_man: has joined #ruby
[01:18:23] bmurt: has joined #ruby
[01:54:27] apparition: has joined #ruby
[01:56:21] brandoncc: has joined #ruby
[02:02:21] catphish: has left #ruby: ("Leaving")
[02:04:35] sonofentropy: has joined #ruby
[02:11:16] ansraliant: has joined #ruby
[02:12:52] duderonomy: has joined #ruby
[02:14:16] nowhere_man: has joined #ruby
[02:14:56] maryo: has joined #ruby
[02:16:42] mikecmpbll: has joined #ruby
[02:16:42] limezzz: has joined #ruby
[02:22:31] tdy: has joined #ruby
[02:35:16] tdy: has joined #ruby
[02:36:40] laaron: has joined #ruby
[03:15:43] paranoic_: has joined #ruby
[03:15:57] Ocampa: has joined #ruby
[03:18:23] akem: has joined #ruby
[03:19:54] Ocampa: Using Manjaro linux, ruby install verified with "ruby -v" command {ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]} - "irb" command not working ("command not found") - am I so daft that I can't get it to run?
[03:26:00] ocampa2: has joined #ruby
[03:30:29] brandoncc: has joined #ruby
[03:33:47] \void: has joined #ruby
[03:36:56] arescorpio: has joined #ruby
[04:04:40] orbyt_: has joined #ruby
[04:08:47] braincrash: has joined #ruby
[04:11:28] [void]: has joined #ruby
[04:11:33] r29v: has joined #ruby
[04:22:23] tdy: has joined #ruby
[04:33:29] esrse: has joined #ruby
[04:38:33] leftylink: ocampa: if manjaro is using arch's package for that, then https://www.archlinux.org/packages/community/any/ruby-irb/ may be necessary
[04:40:47] al2o3-cr: ocampa: whereis irb
[04:42:29] leftylink: whoa, I never knew such a command existed
[04:42:34] al2o3-cr: most likely haven't got it in your PATH
[04:46:54] laaron: has joined #ruby
[04:51:38] kapil____: has joined #ruby
[04:52:04] BTRE: has joined #ruby
[04:52:07] Ocampa: it's showing blank "irb: "
[04:55:18] Ocampa: i have something to go off now, at least. thanks for the link
[04:57:11] al2o3-cr: ocampa: yeah, seems that irb is now a separate package now.
[05:02:12] RiPuk: has joined #ruby
[05:06:50] jottr: has joined #ruby
[05:06:53] ocampa2: has left #ruby: ("saa-recovery.org")
[05:06:54] laaron: has joined #ruby
[05:12:37] jottr: has joined #ruby
[05:17:58] dinfuehr: has joined #ruby
[05:38:03] cnsvc: has joined #ruby
[05:44:28] segy: has joined #ruby
[05:47:53] Leifr: has joined #ruby
[05:57:45] dviola: has joined #ruby
[06:00:00] dinfuehr: has joined #ruby
[06:06:02] dinfuehr: has joined #ruby
[06:18:22] conta: has joined #ruby
[06:21:01] dinfuehr: has joined #ruby
[06:29:32] dinfuehr: has joined #ruby
[06:43:33] dinfuehr: has joined #ruby
[06:48:33] dinfuehr: has joined #ruby
[06:51:15] dellavg_: has joined #ruby
[06:54:58] aupadhye: has joined #ruby
[06:55:51] Furai: has joined #ruby
[07:04:44] dinfuehr: has joined #ruby
[07:05:16] solocshaw: has joined #ruby
[07:09:01] clemens3: has joined #ruby
[07:12:06] reber: has joined #ruby
[07:27:10] _whitelogger: has joined #ruby
[07:44:27] FastJack: has joined #ruby
[07:48:19] za1b1tsu: has joined #ruby
[07:48:22] Swyper: has joined #ruby
[07:49:29] tuor: has joined #ruby
[07:53:17] sauvin: has joined #ruby
[07:54:08] Mortomes|Work: has joined #ruby
[07:56:59] themsay: has joined #ruby
[08:00:19] ItsAVortex: has joined #ruby
[08:08:26] BH23: has joined #ruby
[08:30:30] BH23: has joined #ruby
[08:43:58] hahuang65: has joined #ruby
[08:44:08] paranoicsan: has joined #ruby
[08:51:09] blackmesa1: has joined #ruby
[08:53:34] blackmesa: has joined #ruby
[08:56:17] LightStalker: has joined #ruby
[08:56:31] Swyper: has joined #ruby
[09:04:32] mikecmpbll: has joined #ruby
[09:19:10] nfk: has joined #ruby
[09:25:00] conta: has joined #ruby
[09:43:10] priodev: has joined #ruby
[09:43:17] aufi: has joined #ruby
[09:44:00] Swyper: has joined #ruby
[09:45:23] Nicmavr: has joined #ruby
[09:45:39] jottr: has joined #ruby
[09:45:41] themsay: has joined #ruby
[09:58:55] paranoicsan: has joined #ruby
[10:00:05] snuz: has joined #ruby
[10:05:07] snuz: has joined #ruby
[10:06:36] snuz: has joined #ruby
[10:09:43] ellcs: has joined #ruby
[10:12:24] BH23: has joined #ruby
[10:14:54] kapil____: has joined #ruby
[10:14:58] noboruma: has joined #ruby
[10:35:36] Mortomes|Work_: has joined #ruby
[10:49:55] ntt: has joined #ruby
[10:51:12] ntt: Hello, I'm trying to initialize a new model in a rails application and I'd like to insert a lot of default values. Can I create an hash like default_params = {...} and using it to initialize the model? Furthermore, I need to merge default_params with params I pass through the constructor. Please, someone can help me?
[10:52:08] tbuehlmann: ntt: you can certainly do that. if these defaults are always the same, you could also use after_initialize in your model to set default value
[10:53:16] ntt: tbuehlmann: thank you. Sure, they are always the same. Furthermore, I need to merge my default_params with some params I need to pass as arguments in the new() method. How can I merge in order to have only one hash?
[10:53:39] tbuehlmann: https://gist.github.com/tbuehlmann/0c36c0ac0e81de8b20f54879d3e42227 this will set some_attribute to 'default value' unless it's there
[10:54:01] tbuehlmann: with this, you can simply pass your params into the initializer
[10:54:57] ntt: ok. But the problem is that I have an Hash as default_params and searching on google I found that I can use the method "instance_variable_set". Is this correct?
[10:55:37] tbuehlmann: if the defaults are always the same, you'd just put them into after_initialize, or am I missing something?
[10:55:55] tbuehlmann: (a different option is to have these defaults as database table defaults, btw)
[10:57:00] ntt: yes. I have a looong hash like default_params = {....}. I need to initialize my model with this default_params and others that I'm going to add as params in the new() method
[10:57:44] Guest16678: has joined #ruby
[11:02:18] tbuehlmann: sure, something like this then: https://gist.github.com/tbuehlmann/0c36c0ac0e81de8b20f54879d3e42227
[11:04:00] tbuehlmann: you could replace that hash in line 4 with whatever you have
[11:05:08] laaron: has joined #ruby
[11:05:29] ntt: what is "public_send" ?
[11:05:55] tbuehlmann: some_object.public_send(:foo) is like calling some_object.foo
[11:06:11] tbuehlmann: it let's you dynamically call methods on an object using a symbol
[11:06:23] ntt: NoMethodError: undefined method `range' for #<VExtension:0x0000000005b7b808>
[11:10:00] aqd: has joined #ruby
[11:11:07] snuz: has joined #ruby
[11:16:11] keden: has joined #ruby
[11:37:20] al2o3-cr: has joined #ruby
[11:41:07] minacat: has joined #ruby
[12:03:56] donofrio_: has joined #ruby
[12:08:51] donofrio: has joined #ruby
[12:10:28] paranoicsan: has joined #ruby
[12:10:31] foxxx0: has joined #ruby
[12:20:02] laaron-: has joined #ruby
[12:20:09] minacat: has joined #ruby
[12:20:54] minacat: has left #ruby: ()
[12:28:50] yasumi2136: has joined #ruby
[12:45:01] nowhere_man: has joined #ruby
[12:48:10] BH23: has joined #ruby
[12:51:52] blackmesa: has joined #ruby
[13:08:04] govg: has joined #ruby
[13:12:22] lucasb: has joined #ruby
[13:13:04] dviola: has joined #ruby
[13:27:59] cgfbee: has joined #ruby
[13:28:22] omegaxis: has joined #ruby
[13:32:44] s2013: has joined #ruby
[13:40:58] omegaxis: has joined #ruby
[13:42:19] omegaxis: has joined #ruby
[13:42:44] Leifr: has joined #ruby
[13:43:55] AJA4350: has joined #ruby
[13:44:05] duderonomy: has joined #ruby
[13:49:16] bmurt: has joined #ruby
[13:55:52] ntt: hello, is there a way to make mandatory an attribute in a class? I cannot use ActiveRecord validation because I inherit table structure from an existend db and I cannot write directly on the database (through save() method).
[13:57:06] ntt: I'd like to return an error if I don't pass some params to the new() method and not create the istance of the object
[14:10:48] tuor: has joined #ruby
[14:20:14] stryek: has joined #ruby
[14:21:38] jgpawletko: has joined #ruby
[14:27:22] ramfjord: has joined #ruby
[14:36:47] tdy: has joined #ruby
[14:37:51] za1b1tsu: has joined #ruby
[14:41:40] Dbugger: has joined #ruby
[14:48:45] phaul: ntt: try #RubyOnRails. I can conjure up generic ruby solutions for an arbitrary class, that you controll initialize of, and where attributes are just class attributes. but activerecord/model is slightly different
[14:58:54] KeyJoo: has joined #ruby
[15:10:09] davidw_: has joined #ruby
[15:14:32] Bish: has joined #ruby
[15:14:57] Bish: does somebody here know a good trick to ignore tests when using the github search
[15:16:40] Rapture: has joined #ruby
[15:21:38] polishdub: has joined #ruby
[15:22:18] Inline: has joined #ruby
[15:29:58] rippa: has joined #ruby
[15:39:13] DTZUZO_: has joined #ruby
[15:41:23] bak1an: has joined #ruby
[15:41:25] keden: has joined #ruby
[15:45:17] s2013: has joined #ruby
[15:55:05] omegaxis: has joined #ruby
[15:55:37] omegaxis: has left #ruby: ()
[16:00:38] cranq: has joined #ruby
[16:08:44] brandoncc: has joined #ruby
[16:11:43] brandoncc: has joined #ruby
[16:27:56] conta: has joined #ruby
[16:31:31] snuz: has joined #ruby
[16:34:24] lucasb: has joined #ruby
[16:46:23] maryo: has joined #ruby
[16:51:56] maryo: canton7, if you have a moment can you look at this modification -> https://dpaste.de/sgyk#L24 and tell me whether the File closure is happening properly? Or I am missing something there?
[16:52:12] \void: has joined #ruby
[16:53:38] bruce_lee: has joined #ruby
[16:53:42] canton7: maryo, you call File.open on line 22, and assign that to 'f'. Then you try and open *another* file on line 24, but you don't say that filename to open...
[16:54:25] canton7: maryo, https://dpaste.de/CV6R#L24,26
[16:54:38] TomyLobo: has joined #ruby
[16:54:41] canton7: (which is what I sent you yesterday)
[16:54:55] s2013: has joined #ruby
[16:55:27] maryo: canton7, thanks a lot o/
[16:56:18] orbyt_: has joined #ruby
[17:01:30] vertz: has joined #ruby
[17:02:37] vertz: has left #ruby: ()
[17:02:56] SyedAsif: has joined #ruby
[17:03:46] Cavallari: has joined #ruby
[17:04:16] dellavg_: has joined #ruby
[17:12:28] sonofentropy: has joined #ruby
[17:14:14] omegaxis: has joined #ruby
[17:14:31] omegaxis: hi, how can i use osmesa in ruby?
[17:15:50] orbyt_: has joined #ruby
[17:16:48] \void: has joined #ruby
[17:19:14] maryo: has joined #ruby
[17:23:57] code_zombie: has joined #ruby
[17:26:24] brandoncc: has joined #ruby
[17:48:55] maryo: has joined #ruby
[17:49:32] al2o3-cr: has joined #ruby
[17:49:52] nowhere_man: has joined #ruby
[17:51:01] orbyt_: has joined #ruby
[17:57:00] lxsameer: has joined #ruby
[17:57:30] nowhere_man: has joined #ruby
[17:57:44] ixti: has joined #ruby
[17:59:15] ixti: Is there any nice way to unescape string (not #dump'ed) lie this one: `'[\x22foo\x22,\x22bar\\u1234\x22]'`
[17:59:51] ixti: Easiest way I found is `eval %("#{string}")`
[18:00:17] ixti: but that's not good (due to some obvious reasons).
[18:00:26] gix: has joined #ruby
[18:01:37] ixti: I guess the only way is to actually replace all `/\\x\h{2}` sequences manually.
[18:02:05] ixti: and `\\\\` with `\\`
[18:04:49] maryo_: has joined #ruby
[18:12:55] AJA4351: has joined #ruby
[18:16:54] s2013: has joined #ruby
[18:20:03] mikecmpbll: has joined #ruby
[18:20:19] conta: has joined #ruby
[18:20:49] ixti: Ended up by using `gsub!`
[18:22:43] al2o3-cr: ixti: %("#{str.sub("\\u1234", '')}").undump
[18:22:56] nfk: has joined #ruby
[18:23:24] ixti: Hm... Gonna try that
[18:23:34] al2o3-cr: for this particular string.
[18:23:50] ixti: Yeah. but that was just a very dummy and stupid example
[18:24:00] ixti: real one is a JSON escaped for JS
[18:24:13] ixti: I guess I had to start from that :D
[18:24:42] al2o3-cr: you can undump if hex and unicode aren't mixed, hence the sub otherwise good to go.
[18:25:36] ixti: and if i'm on ruby 2.5 ;))
[18:25:59] al2o3-cr: ixti: what ruby you using?
[18:26:18] ixti: where I need this - 2.4.4
[18:26:45] ixti: I can use a shim for that (backports gem has it)
[18:27:10] al2o3-cr: i thought undump was way before that.
[18:28:29] al2o3-cr: apparently not.
[18:29:47] ixti: Thank you for the tip
[18:30:24] ixti: Tried `undump` (on ruby 2.6) for the real string I had - works like a charm
[18:30:39] ixti: So I'm gonna add a note for myself to switch to undump once ruby is upgraded
[18:35:22] kapil____: has joined #ruby
[18:37:27] al2o3-cr: ixti: is it possible to show the real escaped json?
[18:37:41] al2o3-cr: there might be a better way.
[18:37:44] ixti: Sure. one sec.
[18:39:55] ixti: https://gist.github.com/ixti/39bdc1107891a4955394ce8cfa1688c3 -- looks like this
[18:43:05] bijan_: has joined #ruby
[18:46:45] al2o3-cr: computer says no :P
[18:48:11] ixti: Thanks! :D
[18:49:31] AJA4351: has joined #ruby
[18:57:29] keden: has joined #ruby
[18:57:59] tdy: has joined #ruby
[19:00:46] jinie_: has joined #ruby
[19:09:10] rupam123456: has joined #ruby
[19:19:16] ellcs: has joined #ruby
[19:24:50] cranq: has joined #ruby
[19:32:41] conta: has joined #ruby
[19:32:52] AJA4350: has joined #ruby
[19:36:13] reber: has joined #ruby
[19:38:47] ravenousmoose: has joined #ruby
[19:42:58] troulouliou_div2: has joined #ruby
[19:51:42] nowhere_man: has joined #ruby
[19:54:11] ivanskie: has joined #ruby
[20:03:57] cnsvc: has joined #ruby
[20:10:51] AJA4350: has joined #ruby
[20:13:14] conta: has joined #ruby
[20:14:37] roshanavand: has joined #ruby
[20:31:20] Nirvash: When using splat to accept variable parameters in a method, is there any reason why *args.inject(0){|sum,x| sum+x} would fail?
[20:31:40] Nirvash: I'm getting "unexpected \n" but it makes no sense
[20:33:17] phaul: inject works in an array. args is an array of numbers? then don't splat
[20:34:44] phaul: &>> [1,2,3].inject(0, :+) # Nirvash
[20:34:47] rubydoc: # => 6 (https://carc.in/#/r/649m)
[20:38:38] cubillosxy_py: has joined #ruby
[20:38:47] phaul: when you pass *args as argument, then args is an array in your method no splat needed.. If you want to fill a method call with arguments from an array you do method_call(*ary)
[20:39:40] phaul: btw in recent enough rubies there is also sum
[20:39:47] phaul: &>> [1,2,3].sum
[20:39:49] rubydoc: # => 6 (https://carc.in/#/r/649s)
[20:43:34] jtdowney: has joined #ruby
[20:45:27] ellcs: has joined #ruby
[20:45:39] Nirvash: I see, thank you for that explanation! What I'm trying to do is get a method to accept multiple inputs that may change
[20:45:39] AJA4351: has joined #ruby
[20:45:45] Rapture: has joined #ruby
[20:45:46] phaul: &>> def f(*args); args.sum; end; f(1,2,3)
[20:45:47] rubydoc: # => 6 (https://carc.in/#/r/649v)
[20:45:52] Nirvash: For instance add(1,2) and add(1,2,3) would both work
[20:46:27] Nirvash: "should" both work...
[20:46:28] akem: has joined #ruby
[20:46:42] phaul: Nirvash: the method signature still does *args, but in the body args is the array
[20:46:51] phaul: see my latest example
[20:47:14] drale2k_: has joined #ruby
[20:48:58] phaul: hi baweaver , how's it hangin?
[20:49:20] baweaver: Good good, made some progress on s-expressions and code transformations.
[20:49:43] baweaver: Rubocop has an entire regex-style syntax language for it
[20:49:59] phaul: cool stuff.. sounds interesting.
[20:50:28] baweaver: Ultimate goal is to get a clean upgrade of Rails automated
[20:51:13] baweaver: I think it's possible, just hard.
[20:51:45] phaul: uh, that's a project that actually would be useful. I think I can envisage how one might put it together. Are you open for contributions?
[20:53:38] phaul: I've just seen a post on reddit btw about matching rules on sexps. was that also you?
[20:53:56] phaul: let me try finding it...
[20:54:40] Nirvash: Thank you phaul! I'm just trying to get .sum working now for fun :)
[20:55:13] baweaver: Recently no, but my next stream is on basically this exact subject.
[20:56:16] baweaver: Speaking of, I need to get that event made later.
[20:56:16] Nirvash: Just had to require the correct libraries — thank you all! :)
[20:57:14] cubillosxy_py: hi there someone knows a standar crypt and decrypt that works also in other languages, (python)
[21:01:01] phaul: baweaver: sorry, I can't find it
[21:02:00] phaul: rot13 :) works everywhere
[21:03:07] phaul: ACTION apologises
[21:05:33] baweaver: Technically all of them
[21:05:46] baweaver: ciphers are language agnostic
[21:09:56] havenwood: cubillosxy_py: I'd suggest looking at Ed25519 JWTs for the strong encryption and standard format.
[21:10:42] havenwood: cubillosxy_py: Here's an example of an Ed25519 algo JWT in Ruby: https://gist.github.com/havenwood/b0191cb6749c9c8dc4fb3685961a6916
[21:14:20] cubillosxy_py: havenwood, thanks i gonna check
[21:18:28] blackmesa: has joined #ruby
[21:18:41] themsay: has joined #ruby
[21:19:27] AJA4351: has joined #ruby
[21:19:36] SeepingN: has joined #ruby
[21:29:02] blackmesa1: has joined #ruby
[21:29:46] lytol_: has joined #ruby
[21:39:49] sonofentropy: has joined #ruby
[21:44:51] segy: has joined #ruby
[21:49:19] roshanavand: has joined #ruby
[21:50:55] Fernando-Basso: has joined #ruby
[21:56:24] AJA4351: has joined #ruby
[22:02:44] cd: has joined #ruby
[22:05:05] duderonomy: has joined #ruby
[22:06:28] segy: has joined #ruby
[22:14:46] dviola: has joined #ruby
[22:23:33] helpa: has joined #ruby
[22:26:12] houhoulis: has joined #ruby
[22:27:07] kapil____: has joined #ruby
[22:27:09] ramfjord: has joined #ruby
[22:28:28] DTZUZO: has joined #ruby
[22:38:19] s2013: has joined #ruby
[22:43:41] galaxie: has joined #ruby
[22:44:16] galaxie: I'm trying to figure out what alternatives I have to using a global variable in a medium-sized project of mine.
[22:45:13] galaxie: Basically I want it global because there's a lot of classes that need to access, say, the database connection instance or some config stuff or temporary data.
[22:45:19] phaul: first idea singleton container class?
[22:46:10] AJA4350: has joined #ruby
[22:46:37] galaxie: I've read a little on that, but I'm not sure why it would be better. $global_var versus Global.instance doesn't seem like much a difference
[22:47:34] phaul: as opposed to everybody freely modifying it, the modification of the value still channeled through the class interface
[22:47:54] galaxie: It's just one big hash?
[22:48:47] phaul: not necesarilly. Representation is completely up to what it stores.
[22:49:02] elomatreb: The pattern also has more benefits when testing, since you can start to use things like mock objects
[22:49:26] galaxie: How would that be different than using a different hash?
[22:49:50] phaul: the modifications are all through your predefined class interface
[22:50:20] phaul: you can mock, log, stop it from happening, whatever you need
[22:51:13] galaxie: Again, why couldn't I do that with a Hash or special class?
[22:51:57] phaul: ah. that's not a good idea in general. Inheriting or modifying built in Hash
[22:52:52] galaxie: Didn't think so. But making a class with getters and setters is, well, there's not much difference.
[22:52:59] elomatreb: At a certain point you are right, they are technically very similar and the difference is at least partially aesthetic
[22:54:23] elomatreb: But using a singleton class with a method-based interface is definitely the preferred pattern in the larger ruby community, instead of exposing global "primitive" objects
[22:58:00] keden: has joined #ruby
[23:02:01] ur5us: has joined #ruby
[23:03:15] AJA4351: has joined #ruby
[23:05:11] phaul: just thinking aloud... modifying Hash is obvious why not a good idea. inheriting from Hash is Ok as sonlg as you are creating a general purpose key value store container that works and behaves as such everywhere. But having a hash inside and delegate certain stuff to hash liberates you from all that..
[23:06:01] phaul: if it's hash like data you want to store globally ofc
[23:06:32] ravenousmoose[aw: has joined #ruby
[23:08:53] themsay: has joined #ruby
[23:14:08] tdy: has joined #ruby
[23:16:40] galaxie: I decided I'd use i18n for internationalization, but I'm not sure what feature I'm looking for. Basically my locale files include strings that are formatted like in C's printf, so that calls to localize pass those variables and they are substituted in. What am I looking for here?
[23:17:18] mat_bug: has joined #ruby
[23:20:43] nowhere_man: has joined #ruby
[23:23:39] galaxie: Or do I need to override something somewhere?
[23:29:22] ramfjord: has joined #ruby
[23:36:31] s2013: has joined #ruby
[23:36:42] FernandoBasso: has joined #ruby
[23:38:16] AJA4351: has joined #ruby
[23:45:06] planigan: has joined #ruby
[23:48:09] mat_bug: has joined #ruby
[23:52:25] baweaver: ACTION reads backlog
[23:53:24] baweaver: The reason I'd avoid using a Hash directly is that you can't control what consumers have access to galaxie. In general you want to give the least amount of power and control possible to consumers of code.
[23:53:50] baweaver: As to _why_ you want to do that, if you ever have to refactor it's a mess to clean up a loose interface that's propagated for a few years.
[23:54:43] baweaver: It also lets you define methods and your own API on top of it for accessing things, rather than just a KV store. Your downstream code should not know how to connect to a database, that's none of its business.
[23:55:05] galaxie: I'm sorry, consumers of code?
[23:55:16] baweaver: It should only know that if it sends these values to this other class it has a way to update the database.
[23:55:17] baweaver: Otherwise you end up with your database configuration plastered everywhere in your code.
[23:55:30] baweaver: Every place you perform a db connection using something like that is a consumer
[23:55:40] baweaver: A consumer of a class is something that uses it
[23:55:52] galaxie: No, the DB connection is stored in the hash.
[23:56:12] baweaver: What if the connection fails?
[23:56:29] baweaver: How does the client retry? How does it handle load balancing?
[23:56:46] baweaver: By wrapping that in a class you have more control over these things than just passing a value.
[23:57:14] baweaver: Granted you don't always need that level of granularity
[23:57:28] baweaver: Typically I use classes to define the API I want any code that calls it to see. Giving too much information means implementation details leak
[23:58:16] galaxie: The DB connection would probably be a class that handles everything and the consumer just gives it a query.