<monr0e>
context: I need a global configuration and don't understand ruby well enough yet to choose between a class and module
agrosant has quit [Ping timeout: 264 seconds]
jenrzzz_ has quit [Ping timeout: 252 seconds]
<adam12>
monr0e: The first example is essentially a Singleton. This can be good or bad, depending on your point of view (and the use case).
<monr0e>
It's a similar structure to web.config in asp - it's where anything that needs to be a global configuration value is put
<adam12>
monr0e: A decent compromise might be to use the second example, but assign it to a constant. ie. CONFIG = AppConfig.new(...). It's still a singleton, but you can also initialize instances of it and provide it to places you might need it (ie. testing with different config values).
jenrzzz_ has joined #ruby
<monr0e>
makes it easier to do things like tell a specific page to use a specific code-behind
<monr0e>
hmmm
<adam12>
All of these are fine, but if you aren't familiar with the Singleton pattern it's worth looking up the benefits/drawbacks of using the pattern.
<monr0e>
frankly the nomenclature is... rather foreign to me. My only objective today is to get a single page rendered
<adam12>
Ruby can/will warn if you re-assign a constant, so that's a _minor_ drawback of the singleton pattern in the first example.
<adam12>
Well, Singleton pattern is a common CS expression. It comes from the "gang of four" book Design Patterns: Elements of Reusable Object-Oriented Software
<monr0e>
I did some further looking about, and the idea of using a module seems more appropriate, since I can use `require_relative`
<adam12>
You can use `require_relative` for both/all. There's no difference there.
<monr0e>
Oh, I should look that up. The vast majority of what I learned about OOP came from a head-first book
<adam12>
At this point, any of the examples will work, so just choose the one you like the most.
<adam12>
Singletons have drawbacks. They are convenient but people over-use them. Just be mindful of that and you should be OK.
<monr0e>
Oh, the other consideration is that nothing in the config should be changeable programmatically. I should look into how ruby handles protected objects
<adam12>
In that case, just go with the module/Singleton.
agrosant has joined #ruby
osc4rpt has quit [Ping timeout: 256 seconds]
jenrzzz_ has quit [Ping timeout: 268 seconds]
agrosant has quit [Ping timeout: 264 seconds]
donofrio has joined #ruby
osc4rpt has joined #ruby
jenrzzz_ has joined #ruby
graywolf has quit [Quit: WeeChat 4.0.4]
agrosant has joined #ruby
agrosant has quit [Ping timeout: 264 seconds]
gr33n7007h has quit [Read error: Connection reset by peer]
gr33n7007h has joined #ruby
desnudopenguino1 has joined #ruby
justache is now known as fotastache
desnudopenguino has quit [Ping timeout: 252 seconds]
MomosOrDeath5 has quit [Ping timeout: 260 seconds]
MomosOrDeath53 is now known as MomosOrDeath5
jenrzzz_ has quit [Ping timeout: 272 seconds]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 255 seconds]
<monr0e>
Hurray, I have successfully rendered a page!
xuochi has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 255 seconds]
oneeyedalien has joined #ruby
desnudopenguino1 has joined #ruby
jenrzzz_ has joined #ruby
desnudopenguino has quit [Ping timeout: 268 seconds]
desnudopenguino1 is now known as desnudopenguino
oneeyedalien has quit [Quit: Leaving]
jhass has quit [Remote host closed the connection]
jenrzzz_ has quit [Ping timeout: 256 seconds]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 272 seconds]
Vonter has quit [Ping timeout: 256 seconds]
jenrzzz_ has joined #ruby
Vonter has joined #ruby
Vonter has quit [Quit: WeeChat 4.2.1]
jenrzzz_ has quit [Ping timeout: 268 seconds]
jenrzzz_ has joined #ruby
Sobinec has quit [Ping timeout: 255 seconds]
<adam12>
monr0e: Nice!
jenrzzz_ has quit [Ping timeout: 264 seconds]
jenrzzz_ has joined #ruby
Artea has quit [Ping timeout: 240 seconds]
jenrzzz_ has quit [Ping timeout: 260 seconds]
jenrzzz_ has joined #ruby
jhass has joined #ruby
jhass_ has joined #ruby
jhass has quit [Remote host closed the connection]
jenrzzz_ has quit [Ping timeout: 264 seconds]
jenrzzz_ has joined #ruby
jhass_ is now known as jhass
jenrzzz_ has quit [Ping timeout: 272 seconds]
gaussianblue has quit [Quit: leaving]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 260 seconds]
jenrzzz_ has joined #ruby
donofrio_ has quit [Read error: Connection reset by peer]
donofrio_ has joined #ruby
joako has quit [Quit: quit]
user71 has quit [Quit: Leaving]
<rapha>
havenwood: thanks. that frozen-string-literal-comment is now part of a big fintech product. also, doesn't "it" only work with 3.4.0?
monr0e has quit [Remote host closed the connection]
monr0e has joined #ruby
jenrzzz_ has quit [Ping timeout: 264 seconds]
cek has joined #ruby
jenrzzz_ has joined #ruby
evaloop has joined #ruby
joako has joined #ruby
jenrzzz_ has quit [Ping timeout: 264 seconds]
szkl has quit [Quit: Connection closed for inactivity]
evaloop has left #ruby [Leaving]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 264 seconds]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 272 seconds]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 255 seconds]
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 268 seconds]
_ht has quit [Remote host closed the connection]
Artea has joined #ruby
CRISPR has joined #ruby
raptelan has joined #ruby
jenrzzz_ has joined #ruby
jenrzzz_ has quit [Ping timeout: 272 seconds]
jenrzzz_ has joined #ruby
<raptelan>
I have been trying all day to get Ruby on MacOS to work. But gems keep failing to build with the same C error, on every version of Ruby I've tried between 2.7.2 and 3.3.0. Any ideas? https://dpaste.com/864K2DLCP
<raptelan>
I can build the gem successfully using the built-in Ruby 2.6.10 that came with MacOS. In the past, this same gem was built with the same ruby versions that I'm trying now - not sure what changed.
<raptelan>
I have a Ruby 2.7.7 instance set up with rbenv, which shows posix-spawn 0.3.15 as being installed. But I cannot now use that Ruby version to rebuild it - it hits the same error. That gem hasn't changed since 2020.