bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Swyper has quit [Remote host closed the connection]
apparition has quit [Ping timeout: 250 seconds]
paranoic_ has joined #ruby
ocampa has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
<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?
ocampa2 has joined #ruby
brandoncc has joined #ruby
lytol_ has quit [Remote host closed the connection]
\void has joined #ruby
arescorpio has joined #ruby
cschneid has quit [Remote host closed the connection]
tdy has quit [Ping timeout: 240 seconds]
hurricanehrndz has quit [Quit: Goodbye]
orbyt_ has joined #ruby
braincrash has quit [Quit: bye bye]
arescorpio has quit [Quit: Leaving.]
braincrash has joined #ruby
[void] has joined #ruby
r29v has joined #ruby
\void has quit [Read error: Connection reset by peer]
cgfbee has quit [Remote host closed the connection]
limezzz has quit [Remote host closed the connection]
Inline has quit [Quit: Leaving]
dinfuehr has quit [Ping timeout: 250 seconds]
dinfuehr has joined #ruby
dinfuehr has quit [Ping timeout: 245 seconds]
dinfuehr has joined #ruby
dellavg_ has joined #ruby
Furai has quit [Quit: WeeChat 2.3]
aupadhye has joined #ruby
Furai has joined #ruby
dinfuehr has quit [Ping timeout: 246 seconds]
dinfuehr has joined #ruby
solocshaw has joined #ruby
clemens3 has joined #ruby
solocshaw has quit [Quit: solocshaw]
reber has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
nowhere_man has quit [Ping timeout: 252 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
_whitelogger has joined #ruby
FastJack has joined #ruby
za1b1tsu has joined #ruby
Swyper has joined #ruby
Tuor has joined #ruby
sauvin has joined #ruby
Mortomes|Work has joined #ruby
themsay has joined #ruby
ItsAVortex has joined #ruby
brandoncc has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
BH23 has joined #ruby
Swyper has quit [Remote host closed the connection]
BH23 has quit [Ping timeout: 250 seconds]
Leifr has quit [Ping timeout: 245 seconds]
dviola has quit [Quit: WeeChat 2.3]
ansraliant has quit [Quit: My planet needs me]
jcarl43 has quit [Quit: WeeChat 2.3]
BH23 has joined #ruby
conta has quit [Ping timeout: 250 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hahuang65 has joined #ruby
paranoicsan has joined #ruby
hahuang6- has quit [Ping timeout: 268 seconds]
blackmesa1 has joined #ruby
blackmesa has joined #ruby
lightstalker has quit [Ping timeout: 246 seconds]
blackmesa1 has quit [Ping timeout: 252 seconds]
lightstalker has joined #ruby
Swyper has joined #ruby
Swyper has quit [Ping timeout: 245 seconds]
Tuor has quit [Ping timeout: 246 seconds]
mikecmpbll has joined #ruby
reber has quit [Remote host closed the connection]
postmodern has quit [Quit: Leaving]
nfk has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
themsay has quit [Ping timeout: 250 seconds]
conta has joined #ruby
BH23 has quit [Ping timeout: 244 seconds]
cnsvc has quit [Ping timeout: 256 seconds]
paranoicsan is now known as paranoicsan[Away
paranoicsan[Away has quit [Quit: paranoicsan[Away]
priodev has quit [Quit: out.]
priodev has joined #ruby
aufi has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Swyper has joined #ruby
Nicmavr has joined #ruby
jottr has joined #ruby
themsay has joined #ruby
Swyper has quit [Ping timeout: 272 seconds]
ItsAVortex has quit [Quit: Leaving]
paranoicsan has joined #ruby
snuz has joined #ruby
noboruma has quit [Quit: leaving]
snuz has quit [Client Quit]
snuz has joined #ruby
snuz has quit [Client Quit]
snuz has joined #ruby
ellcs has joined #ruby
agent_white has quit [Quit: bbl]
BH23 has joined #ruby
kapil____ has joined #ruby
noboruma has joined #ruby
themsay has quit [Ping timeout: 272 seconds]
snuz has quit [Quit: WeeChat 2.3]
Mortomes|Work_ has joined #ruby
stryek has quit [Quit: Connection closed for inactivity]
Mortomes|Work has quit [Ping timeout: 256 seconds]
paranoicsan is now known as paranoicsan[Away
ntt has joined #ruby
<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?
paranoicsan[Away is now known as paranoicsan
<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
<tbuehlmann>
values*
<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?
<tbuehlmann>
with this, you can simply pass your params into the initializer
<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?
<tbuehlmann>
if the defaults are always the same, you'd just put them into after_initialize, or am I missing something?
<tbuehlmann>
(a different option is to have these defaults as database table defaults, btw)
<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
yasumi2136 has quit [Quit: Konversation terminated!]
nfk has quit [Quit: Try memory.free_dirty_pages=true in about:config]
nowhere_man has joined #ruby
blackmesa has quit [Ping timeout: 250 seconds]
BH23 has joined #ruby
nowhere_man has quit [Ping timeout: 240 seconds]
blackmesa has joined #ruby
govg has joined #ruby
lucasb has joined #ruby
dviola has joined #ruby
kapil____ has quit [Quit: Connection closed for inactivity]
Mortomes|Work_ has quit [Ping timeout: 256 seconds]
cgfbee has joined #ruby
omegaxis has joined #ruby
s2013 has joined #ruby
cgfbee has quit [Remote host closed the connection]
omegaxis has quit [Quit: leaving]
omegaxis has joined #ruby
omegaxis has quit [Client Quit]
cd has quit [Quit: cd]
omegaxis has joined #ruby
Leifr has joined #ruby
AJA4350 has joined #ruby
duderonomy has joined #ruby
bmurt has joined #ruby
<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).
<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
paranoicsan has quit [Quit: paranoicsan]
omegaxis has quit [Ping timeout: 250 seconds]
Tuor has joined #ruby
stryek has joined #ruby
dviola has quit [Ping timeout: 252 seconds]
jgpawletko has joined #ruby
clemens3 has quit [Ping timeout: 240 seconds]
ramfjord has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tdy has joined #ruby
za1b1tsu has joined #ruby
cranq has quit [Ping timeout: 272 seconds]
Dbugger has joined #ruby
conta has quit [Ping timeout: 246 seconds]
<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
KeyJoo has joined #ruby
za1b1tsu has quit [Remote host closed the connection]
davidw_ has joined #ruby
Bish has joined #ruby
<Bish>
does somebody here know a good trick to ignore tests when using the github search
Rapture has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
brandoncc has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
conta has joined #ruby
liya has quit [Quit: ZNC 1.6.5+deb1+deb9u1 - http://znc.in]
BH23 has quit [Ping timeout: 240 seconds]
snuz has joined #ruby
snuz has quit [Client Quit]
conta has quit [Ping timeout: 240 seconds]
lucasb has joined #ruby
ellcs has quit [Ping timeout: 250 seconds]
maryo has joined #ruby
dellavg_ has quit [Ping timeout: 250 seconds]
<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?
\void has joined #ruby
bruce_lee has joined #ruby
<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...
<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)
<phaul>
btw in recent enough rubies there is also sum
helpa has quit [Remote host closed the connection]
helpa has joined #ruby
houhoulis has joined #ruby
kapil____ has joined #ruby
ramfjord has joined #ruby
DTZUZO_ has quit [Quit: WeeChat 2.0]
DTZUZO has joined #ruby
AJA4350 has quit [Ping timeout: 240 seconds]
moei has quit [Quit: Leaving...]
keden has quit [Ping timeout: 272 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
s2013 has joined #ruby
galaxie has joined #ruby
<galaxie>
I'm trying to figure out what alternatives I have to using a global variable in a medium-sized project of mine.
<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.
<phaul>
first idea singleton container class?
AJA4350 has joined #ruby
Leifr has quit [Quit: Going offline, see ya! (www.adiirc.com)]
<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
<phaul>
as opposed to everybody freely modifying it, the modification of the value still channeled through the class interface
<galaxie>
It's just one big hash?
<phaul>
not necesarilly. Representation is completely up to what it stores.
<elomatreb>
The pattern also has more benefits when testing, since you can start to use things like mock objects
<galaxie>
How would that be different than using a different hash?
<phaul>
the modifications are all through your predefined class interface
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<phaul>
you can mock, log, stop it from happening, whatever you need
<galaxie>
Again, why couldn't I do that with a Hash or special class?
<phaul>
ah. that's not a good idea in general. Inheriting or modifying built in Hash
<galaxie>
Didn't think so. But making a class with getters and setters is, well, there's not much difference.
<elomatreb>
At a certain point you are right, they are technically very similar and the difference is at least partially aesthetic
<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
nfk has quit [Quit: Try memory.free_dirty_pages=true in about:config]
cubillosxy_py has quit [Ping timeout: 250 seconds]
<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..
<phaul>
if it's hash like data you want to store globally ofc
ravenousmoose[aw has joined #ruby
ravenousmoose[aw has quit [Client Quit]
themsay has quit [Ping timeout: 246 seconds]
themsay has joined #ruby
polishdub has quit [Remote host closed the connection]
gix has quit [Disconnected by services]
tdy has joined #ruby
<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?
mat_bug has joined #ruby
nowhere_man has joined #ruby
mat_bug has quit [Ping timeout: 252 seconds]
<galaxie>
Or do I need to override something somewhere?
houhoulis has quit [Remote host closed the connection]
planigan has quit [Ping timeout: 250 seconds]
troulouliou_div2 has quit [Read error: Connection reset by peer]
roshanavand has quit [Remote host closed the connection]
ramfjord has joined #ruby
TomyLobo has quit [Read error: Connection reset by peer]
maryo_ has quit [Ping timeout: 245 seconds]
s2013 has joined #ruby
FernandoBasso has joined #ruby
AJA4351 has joined #ruby
AJA4350 has quit [Ping timeout: 245 seconds]
AJA4351 is now known as AJA4350
Fernando-Basso has quit [Ping timeout: 252 seconds]
ur5us has quit [Read error: Connection reset by peer]
planigan has joined #ruby
FernandoBasso has quit [Remote host closed the connection]
mat_bug has joined #ruby
* baweaver
reads backlog
<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.
<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.
<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.
<galaxie>
I'm sorry, consumers of code?
<baweaver>
It should only know that if it sends these values to this other class it has a way to update the database.
<baweaver>
Otherwise you end up with your database configuration plastered everywhere in your code.
<baweaver>
Every place you perform a db connection using something like that is a consumer
<baweaver>
A consumer of a class is something that uses it
bruce_lee has quit [Remote host closed the connection]
<galaxie>
No, the DB connection is stored in the hash.
<baweaver>
What if the connection fails?
<baweaver>
How does the client retry? How does it handle load balancing?
<baweaver>
By wrapping that in a class you have more control over these things than just passing a value.
<baweaver>
Granted you don't always need that level of granularity
<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
<galaxie>
The DB connection would probably be a class that handles everything and the consumer just gives it a query.