adam12 changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.0.3, 2.7.5, 2.6.9: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
dviola has quit [Ping timeout: 256 seconds]
roadie has joined #ruby
roshanavand_ has joined #ruby
roadie has quit [Ping timeout: 268 seconds]
ur5us_ has joined #ruby
roshanavand has quit [Ping timeout: 252 seconds]
roshanavand__ has joined #ruby
roshanavand_ has quit [Ping timeout: 256 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 268 seconds]
swaggboi has joined #ruby
michigan has quit [Quit: Connection closed for inactivity]
Pipip has joined #ruby
roshanavand__ has quit [Ping timeout: 240 seconds]
ur5us_ has quit [Ping timeout: 240 seconds]
aindilis_ has quit [Quit: ZNC 1.7.2+deb3 - https://znc.in]
roadie has joined #ruby
hololeap_ has joined #ruby
hololeap has quit [Read error: Connection reset by peer]
Rounin has quit [Ping timeout: 245 seconds]
roadie has quit [Ping timeout: 268 seconds]
lim has quit [Quit: WeeChat 3.2.1]
niv has quit [Quit: Powered by LunarBNC: https://LunarBNC.net]
<libsys> hello people... question, how could I execute a lambda within an specific context? I'm trying to allow lambdas/procs that can use methods from an specific class, but defining these lambdas outside of the class instance
<libsys> e.g: class MyClass; def mymethod; 'helo' end; end ... my_obj = MyClass.new; my_obj.lambda { "#{mymethod} world" }
<havenwood> libsys: my_obj.class_eval { puts mymethod }
<havenwood> I mean instance_eval.
<havenwood> my_obj.instance_eval { puts mymethod }
<havenwood> or: my_obj.then { |obj| obj.mymethod }
<libsys> I need it to be a lambda because it's defined through configuration... probably I could simply execute the lambda within instance_eval?
<libsys> would that recognize the scope?
<havenwood> libsys: my_obj.instance_eval { ->{ mymethod } }.call #=> "hell"
<havenwood> libsys: try in irb
orbyt_v10 has joined #ruby
<libsys> says "undefined local variable or method `my_method' for main:Object" because lambda binds the scope where it's been defined
<libsys> is there a way to alter the scope of a function/proc/lambda?
<libsys> I could make a trick to pass the instance of my_obj into the lambda through a parameter though... probably that's my best bet :/
finstern1s is now known as finsternis
roshanavand__ has joined #ruby
roadie has joined #ruby
aindilis has joined #ruby
finsternis has quit [Quit: leaving]
roadie has quit [Ping timeout: 240 seconds]
finsternis has joined #ruby
jhass has quit [Ping timeout: 240 seconds]
niv has joined #ruby
roadie has joined #ruby
<havenwood> libsys: I meant: my_obj.instance_eval { my_lambda = -> { "#{my_method} world" } }
<havenwood> libsys: my_lambda.call
<havenwood> libsys: alternatively you can pass a binding to a lambda
roadie has quit [Ping timeout: 240 seconds]
<Pipip> So is BasicObject an Object?
<havenwood> Pipip: Yes.
<Pipip> What does that mean?
<Pipip> So BasicObject is the class of Object
<Pipip> *superclass
<havenwood> Pipip: Yeah, Object.superclass #=> Basic_object
<havenwood> BasicObject.superclass #=> nil
<havenwood> BasicObject.instance_of? Class #=> true
<havenwood> Class.superclass #=> Module
<havenwood> Module.superclass #=> Object
<havenwood> Object.superclass #=> BasicObject
hololeap_ is now known as hololeap
roshanavand_ has joined #ruby
roshanavand__ has quit [Ping timeout: 256 seconds]
shiru has joined #ruby
easbarba` has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
easbarba has quit [Ping timeout: 268 seconds]
FetidToot has joined #ruby
roshanavand_ has quit [Ping timeout: 240 seconds]
BSaboia has joined #ruby
orbyt_v10 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest4525 has joined #ruby
Guest4525 has quit [Client Quit]
orbyt_v10 has joined #ruby
reset has quit [Quit: reset]
BSaboia has quit [Quit: This computer has gone to sleep]
gr33n7007h has joined #ruby
reset has joined #ruby
BSaboia has joined #ruby
huma has joined #ruby
jimeh has quit [Remote host closed the connection]
jimeh has joined #ruby
sagax has joined #ruby
roadie has joined #ruby
roadie has quit [Ping timeout: 252 seconds]
shiru has quit [Quit: leaving]
<Pipip> That makes sense
roadie has joined #ruby
hololeap has quit [Remote host closed the connection]
hololeap has joined #ruby
huma has quit [Ping timeout: 240 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
orbyt_v10 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_ht has joined #ruby
Pipip has quit [Quit: Ex-Chat]
huma has joined #ruby
roadie has quit [Ping timeout: 268 seconds]
roadie has joined #ruby
jhass has joined #ruby
michigan has joined #ruby
Rounin has joined #ruby
roadie has quit [Quit: ERC (IRC client for Emacs 25.3.50.1)]
BSaboia has joined #ruby
BSaboia has quit [Read error: Connection reset by peer]
huma has quit [Ping timeout: 240 seconds]
perrierjouet has joined #ruby
perrierjouet has left #ruby [WeeChat 3.3]
BSaboia has joined #ruby
BSaboia has quit [Client Quit]
nucranium has quit [Quit: Konversation terminated!]
BSaboia has joined #ruby
<nakilon> wait so BasicObject is a class and an instance?
dka_ has quit [Quit: My Ex-Girlfriend once told me: I'm not a slut, I'm just popular]
dka has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
BSaboia has joined #ruby
BSaboia has quit [Client Quit]
<nakilon> Class.class => Class _<>
phryk has quit [Quit: ZNC 1.8.2 - https://znc.in]
phryk has joined #ruby
<ccooke> nakilon: Everything in Ruby is an instance of a class. So BasicObject is an instance of class Class.
BSaboia has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
BSaboia has joined #ruby
FetidToot has quit [Ping timeout: 240 seconds]
fef has joined #ruby
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
yxhuvud has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
FetidToot has joined #ruby
BSaboia has joined #ruby
vigumnov has joined #ruby
victori has quit [Read error: Connection reset by peer]
lim has joined #ruby
lim has quit [Quit: WeeChat 3.2.1]
tkonto has joined #ruby
michigan has quit [Quit: Connection closed for inactivity]
michigan has joined #ruby
teclator has quit [Ping timeout: 268 seconds]
gr33n7007h has quit [Quit: WeeChat 3.4]
teclator has joined #ruby
tkonto has quit [Quit: tkonto]
Tempesta has quit [Quit: See ya!]
robotmay has quit [Quit: No Ping reply in 180 seconds.]
robotmay has joined #ruby
Tempesta has joined #ruby
BSaboia has quit [Quit: Leaving]
<havenwood> ny
huma has joined #ruby
sylario has joined #ruby
<sylario> How do you call the method call a class make when it's instanciated ? like has_many or validate
<sylario> What's the patten/metaprograming name for it?
huma has quit [Ping timeout: 240 seconds]
<adam12> sylario: class methods?
<sylario> yeah but it does not really convey the "designed to be call at class instanciation" part.
<sylario> Maybe DSL
fef has quit [Ping timeout: 276 seconds]
___nick___ has joined #ruby
Al2O3 has quit [Ping timeout: 240 seconds]
gr33n7007h has joined #ruby
lim has joined #ruby
swaggboi has quit [Ping timeout: 268 seconds]
Al2O3 has joined #ruby
lim has quit [Remote host closed the connection]
lim has joined #ruby
ur5us_ has joined #ruby
Cork has quit [Ping timeout: 256 seconds]
lim has quit [Ping timeout: 256 seconds]
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
___nick___ has quit [Ping timeout: 240 seconds]
_ht has quit [Remote host closed the connection]
<havenwood> sylario: I think you mean at runtime rather than on class instanciation?
<havenwood> Class instantiation is like Foo.new.
<havenwood> sylario: In the case of `has_many` it's a class method, like adam12 said. It's defined in a module then included. See https://github.com/rails/rails/blob/v7.0.0/activerecord/lib/active_record/associations.rb#L1445-L1448
<havenwood> You can do the same yourself. See Rails concerns for Rails-specific concerns.
<sylario> Yes technically, I get it's a class method, but on a conceptual level 'class method called at the root of a class' are not the same than SomeService.call().
<sylario> I am a bit surprised there is no word to designate them
<havenwood> sylario: Yeah, at top level inside a class the receiver is self, so while they're still just class methods you can drop the explicit receiver.
<havenwood> `class Foo; has_many end` is the same as `class Foo; self.has_many end` which is the same as `class Foo; Foo.has_many end`
<sylario> Ok
<havenwood> sylario: Similarly in an instance of a class you can do implicit self with instance methods. There's not a special name since it's really not a particularly special case.
<havenwood> They're just plain 'ole class methods referenced inside the class at top level.
<havenwood> You can write it Foo.has_many for an explicit version.
<sylario> Thx
<havenwood> np
hololeap has quit [Excess Flood]
hololeap has joined #ruby
Cork has joined #ruby
Rounin has quit [Ping timeout: 268 seconds]
samgranieri has joined #ruby
<sagax> hi all
<sagax> on page of `gem server` i see some errors about `stylesheet 404, javascript 404` - how fix `gem server` for read rdoc?
teclator has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
Cork has quit [Ping timeout: 256 seconds]
<havenwood> sagax: I've not seen 404s with gem server before. Share a gist with the full error?