wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
wallace_mu has quit [Ping timeout: 260 seconds]
va5c0 has joined #ruby
akem__ is now known as akem
va5c0 has quit [Ping timeout: 240 seconds]
cnsvc has joined #ruby
chouhoulis has quit [Remote host closed the connection]
apotheon_ has joined #ruby
apotheon has quit [Ping timeout: 256 seconds]
tsujp2 has joined #ruby
<tsujp2>
Friends, does anyone here know about Rails association lambda scopes? e.g. what in the blazes is `has_many :articles, -> { foo }`? I understand if it had a `where` condition inside the inline block etc but not a literal `foo`
<tsujp2>
Asked on RoR channel but no response and I've been stuck on this for 2 hours now, and I can find no explained example on the web
alfiemax has quit [Remote host closed the connection]
alfiemax has quit [Remote host closed the connection]
BSaboia has quit [Quit: This computer has gone to sleep]
<tsujp2>
the ruby way of referring to an instance varialbe is `@` right?
<tsujp2>
similar to how `#` refers to instance methods, and `.` to class methods?
akem has quit [Ping timeout: 265 seconds]
BSaboia has joined #ruby
tsujp2 has quit [Quit: Ping timeout (120 seconds)]
BSaboia has quit [Quit: This computer has gone to sleep]
schne1der has joined #ruby
Stanislaus has joined #ruby
imode has joined #ruby
Rudd0 has quit [Ping timeout: 256 seconds]
Stanislaus has quit [Ping timeout: 245 seconds]
tobiasvl has quit [Ping timeout: 244 seconds]
tvl has joined #ruby
tvl is now known as tobiasvl
alfiemax has joined #ruby
vondruch has joined #ruby
vondruch has quit [Remote host closed the connection]
vondruch has joined #ruby
cd has quit [Quit: cd]
phage has joined #ruby
BSaboia has joined #ruby
kristian_on_linu has joined #ruby
<yxhuvud>
tsujp2: foo looks like a method call. What does it return?
ur5us has joined #ruby
olblak has quit [Remote host closed the connection]
phage has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cnsvc has quit [Ping timeout: 240 seconds]
phage has joined #ruby
Ediz has joined #ruby
imode has quit [Ping timeout: 265 seconds]
akem has joined #ruby
akem has quit [Remote host closed the connection]
akem has joined #ruby
Ediz has quit [Remote host closed the connection]
Ediz has joined #ruby
Ediz is now known as Guest34458
rafadc has quit [Read error: Connection reset by peer]
rafadc has joined #ruby
dionysus69 has joined #ruby
ediz_ has joined #ruby
Guest34458 has quit [Ping timeout: 260 seconds]
braincrash has joined #ruby
phage has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 240 seconds]
alfiemax has quit [Remote host closed the connection]
akem has quit [Quit: bbl]
phage has joined #ruby
phage has quit [Client Quit]
tsujp31 has joined #ruby
sagax has joined #ruby
<tsujp31>
Given this EXTREMELY simple example how can I conditionally upcase `foo` without repeating the variable `foo` in code? https://dpaste.org/Bs8K
<tsujp31>
if switch is `false` it doesn't print, I want it to print `value` if switch is false, and `VALUE` if switch is true without repeating `foo`
<tsujp31>
i.e. to conditionally apply the method `.upcase`
Furai has quit [Quit: WeeChat 2.9]
Furai has joined #ruby
Rudd0 has joined #ruby
wallace_mu has joined #ruby
wallace_mu has quit [Ping timeout: 256 seconds]
akem has joined #ruby
tsujp31 has quit [Remote host closed the connection]
<Caius>
tsujp: `puts value.instance_eval { upcase if switch }`
<Caius>
Hm, no, doesn't print if switch is false.
<Caius>
You could put `foo.upcase! if switch` on the line above the puts
<Caius>
Or lean on `tap` to inline it - `puts value.tap { |v| v.upcase! if switch }`
vondruch_ has joined #ruby
phage has joined #ruby
vondruch has quit [Ping timeout: 240 seconds]
vondruch_ is now known as vondruch
Arkantos has quit [Quit: ZNC 1.6.6+deb1ubuntu0.2 - http://znc.in]
AndreYuhai has joined #ruby
<jhass>
in other words, it's not worth it, just repeat it :)
<jhass>
(upcase! likely will have side effects you don't want)
<AndreYuhai>
What is better? attrs ||= {} or attrs&.each ?
<jhass>
I think that depends on context
<jhass>
a third option: raise ArgumentError if attrs.nil?
<AndreYuhai>
jhass, But I need to rescue it anyway
<AndreYuhai>
jhass, it has to work when the attrs is nil as well
<AndreYuhai>
I can just log it somewhere that it was nil
<jhass>
sure, I said it depends on context and some contexts I would prefer to reject it
<jhass>
in other words, I think you made the question way too general and abstract :)
<jhass>
if going for attrs ||= {} I would make the default value nil
<AndreYuhai>
Oh sorry for that. So in my case I need to handle it even if it's nil. :D
<jhass>
attrs&. vs attrs ||= (without further contex) is really more of a mood of the day question for me
<jhass>
if I have many usages of attrs where the default value makes sense I would probably prefer it
<jhass>
for a single call it's pretty, eh, whatever
phage has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TomyWork has joined #ruby
<AndreYuhai>
jhass, Doesn't really make a difference in my case then. Because The only thing I am doing with attrs is setting up instances variables and their readers nothing else.
<AndreYuhai>
jhass, I just don't want each to throw an error on nil :D
weaksauce has quit [Ping timeout: 256 seconds]
ediz_ has quit [Ping timeout: 264 seconds]
Ediz has joined #ruby
<Ediz>
Hello
<Ediz>
writing my first ruby app here... can't figure out why these attributes are not set - missing something very simple probably, can someone have a look? https://hastebin.com/xocajeyacu.rb
<Ediz>
thanks in advance
ua has quit [Excess Flood]
<jhass>
Ediz: so your table has these attributes? (uuid, api_key, user)
<Ediz>
yes
<jhass>
then just drop the attr_accessor line
ua has joined #ruby
<Ediz>
its not needed?
<jhass>
AR creates accessors for any table columns automatically
<Ediz>
ah right
<jhass>
you can also get rid of setting the table name if you call the model ApiUser, possibly inside a namespace module Models; class ApiUser < ....
<Ediz>
it was defaulting to the table name derived from class name
<Ediz>
so I added it
Ediz has quit [Remote host closed the connection]
Ediz has joined #ruby
<Ediz>
it was defaulting to the table name derived from class name
<Ediz>
so I added it
<Ediz>
sorry, d/c'd momentarily
<jhass>
yes, that's my point, moving it inside a namespace rather than using an unconventional name should free you from the cofniguration :)
<Ediz>
by namespace, you mean a module right?
<jhass>
yes
<Ediz>
you're right, I should look into this. I'm also still very rough on loading dependencies using require - should help that too I believe
<Ediz>
might be unrelated lol
ellcs has joined #ruby
<Ediz>
is there a specific way to handle require statements to different files and folders?
<Ediz>
what I'm doing feels wrong, requiring files with paths according to each class
<jhass>
require_relative is to prefer for relative requires, require './' is dependent on the working directory
<jhass>
require operates on files alone, what to put in them is only governed by convention
<jhass>
the common convention is to have FooBar::Baz::Quux defiend in foo_bar/baz/quux.rb and require'd with require 'foo_bar/baz/quux' (given a properly setup $LOAD_PATH). Also for non-rails projects a lot of people follow the convention for a gem, with a lib/ folder for the app code, a bin/ folder for entrypoint "executables" and a test/ or spec/ folder for tests
<jhass>
but while you're starting out, whatever works works :)
<Ediz>
I'm so used to creating one file for each class
<jhass>
which most people still do :)
<jhass>
fairly often you find a small class nested in the file defining it's namespace module
<jhass>
(just ignore the stuff specific to creating a gem)
<Ediz>
can't wait to complete this service so I can get an overall review of what I've put together
<Ediz>
thx for the help, I appreciate it
<jhass>
yw :)
phage has joined #ruby
akem has joined #ruby
banisterfiend has joined #ruby
ellcs has quit [Ping timeout: 260 seconds]
banisterfiend has quit [Read error: Connection reset by peer]
drincruz has joined #ruby
alfiemax has joined #ruby
alexherbo2 has joined #ruby
envex has quit []
elcuervo has quit [Read error: Connection reset by peer]
meinside has quit [Quit: Connection closed for inactivity]
elcuervo has joined #ruby
akem has quit [Ping timeout: 265 seconds]
jordanm has quit [Ping timeout: 260 seconds]
bmurt has joined #ruby
jordanm has joined #ruby
mensvaga has joined #ruby
<mensvaga>
What's a good way to use Dir['some_path/**'] in conjunction with a .gitignore? I want to filter out entries that would correspond to entries in a .gitignore
Ediz has quit [Read error: Connection reset by peer]
<mensvaga>
I'm thinking along the lines of https://stackoverflow.com/a/15511438 , where I do a .select , but I don't know if there's a simple comparison mechanism to use with the entries Dir returns and what's in the .gitignore
<mensvaga>
... maybe I should just use the output of 'git ls-tree'
<jhass>
sure, sounds fair
<mensvaga>
Yeah; if the syntax of .gitignore had something easy to implement in Ruby, I'd probably do it that way instead of shelling out
<mensvaga>
but if I'm going to use .gitignore anyway, I may as well shell out to git.
<jhass>
I still believe fnmatch gets you 90% there, just gotta handle !
<nakilon>
do the `git ls-tree ...` command and use Array intersections, etc.
<mensvaga>
Yeah, probably because it ties it to a specific revision control system?
<mensvaga>
I mean, if the tree was checked out "fresh" from a tag from a repo, you wouldn't have to worry about files that are "ignored" because they shouldn't even be there
<jhass>
because your .gem should ship your .git
<jhass>
*should not, duh
<jhass>
read the guide, it has all the rationale :)
<nakilon>
where did I say he should use git in gemspec?
<nakilon>
oh I see, I didn't , he did
<mensvaga>
You didn't say "should", you said, "like some people do"
<jhass>
*they did for all we know :P
olblak has joined #ruby
<mensvaga>
Yeah. Says use "dir".
wallace_mu has joined #ruby
<nakilon>
I stopped using git in gemspec when realised that gem installation does not need all the stuff like tests, CI configs, etc.
<mensvaga>
I thiiiiink at one point in time bundler on Ubuntu used git ls-files by default
<mensvaga>
So, I just need to "look up" the tree and gather entries for .gitignore, and if there are entries, then exclude them
<mensvaga>
That way, stuff that doesn't have git won't fail, and I can do tests from my dev repo
<mensvaga>
And the overall affect will still be repo system agnostic
<mensvaga>
What does the "*" do in "*File.read" ? does that convert it to an array?
<jhass>
.split makes it an array (splits on any consecutive whitespace)
<jhass>
* takes that array and passes it as an argument list
<jhass>
it's called splatting
<mensvaga>
Ah. So that's how "blank" entries wouldn't show up if you had consecutive newlines. However, that doesn't take care of comments in the gitignore.
<mensvaga>
jhass: Ah. Right. Perl calls that "flattening", which it does by default
<jhass>
yeah, I'm also not sure it'll handle ! properly and things like that. Also it doesn't handle nested .gitignore's as you already noticed and requires shipping .gitignore files in the .gem, which you could also view as superfluous
<mensvaga>
Maybe it is pointless anyway; I mean, no production gems should be built from a dirty repo
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
teardown has joined #ruby
akem_ has joined #ruby
akem has quit [Ping timeout: 240 seconds]
elxbarbosa has quit [Remote host closed the connection]
ellcs has quit [Ping timeout: 260 seconds]
lightstalker has quit [Ping timeout: 260 seconds]
lightstalker has joined #ruby
impermanence has joined #ruby
rafadc has quit [Read error: Connection reset by peer]
rafadc has joined #ruby
dionysus69 has quit [Quit: dionysus69]
dionysus69 has joined #ruby
arca0 has left #ruby ["Kicked by @appservice-irc:matrix.org : Idle for 30+ days"]
dionysus69 has quit [Ping timeout: 256 seconds]
ramfjord has joined #ruby
va5c0 has quit [Ping timeout: 260 seconds]
cthu| has joined #ruby
mao has joined #ruby
lightstalker has quit [Ping timeout: 272 seconds]
troulouliou_div2 has joined #ruby
lightstalker has joined #ruby
akem_ is now known as akem
alexherbo22 has joined #ruby
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo22 is now known as alexherbo2
ChmEarl has joined #ruby
alexherbo23 has joined #ruby
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo23 is now known as alexherbo2
troulouliou_div2 has quit [Ping timeout: 272 seconds]
elxbarbosa has joined #ruby
ramfjord has quit [Ping timeout: 260 seconds]
ramfjord has joined #ruby
neshpion has joined #ruby
dionysus69 has joined #ruby
pgib has joined #ruby
greengriminal has joined #ruby
elxbarbo` has joined #ruby
elxbarbosa has quit [Ping timeout: 246 seconds]
davispuh has joined #ruby
Milos has quit [Remote host closed the connection]
TomyWork has quit [Quit: Leaving]
Milos has joined #ruby
reyfi9e has joined #ruby
cnsvc has joined #ruby
weaksauce has joined #ruby
weaksauce has quit [Client Quit]
kent\n is now known as Mickey_Mouse
Mickey_Mouse is now known as kent\n
weaksauce has joined #ruby
powerhouse has quit [Read error: Connection reset by peer]
powerhouse has joined #ruby
imode has joined #ruby
alfiemax has quit [Remote host closed the connection]
adu has quit [Ping timeout: 246 seconds]
<AndreYuhai>
I do not need to use the Module name in a class referencing another class in the same module, right?
<AndreYuhai>
Like when I want to use Baz in Foo::Bar I just use Baz not Foo::Baz
TCZ has joined #ruby
tuttzza has quit [Ping timeout: 260 seconds]
gix has joined #ruby
chouhoulis has joined #ruby
<adam12>
AndreYuhai: Most of the time yes, but if you use the shorthand syntax to define your class, beware the scope of module lookup changes.
<adam12>
ie. module Foo; class Bar; is different than class Foo::Bar.
<adam12>
In the former, inside Bar, you can say Baz and it will look in Foo as well, but in the latter, it will loo kfor Baz at the top level and not find Foo::Baz.
Rudd0 has quit [Ping timeout: 246 seconds]
elxbarbo` has quit [Ping timeout: 272 seconds]
neshpion has quit [Quit: WeeChat 2.9]
aandrew has joined #ruby
CrazyEddy has quit [Ping timeout: 246 seconds]
cd has joined #ruby
schne1der has quit [Ping timeout: 258 seconds]
bmurt has joined #ruby
mao has quit []
<AndreYuhai>
I've got a Sidekiq worker and I would like to get the statistics about the jobs executed by the worker. For example how many of them inserted some data into the db and etc. Is it possible with Sidekiq?
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]