These are chat archives for dry-rb/chat

30th
Apr 2016
Tim Riley
@timriley
Apr 30 2016 04:18
errr….
in a debugger inside an #initialize method:
(byebug) method(__method__).super_method.arity
1

(byebug) super()
nil

(byebug) super({})
*** ArgumentError Exception: wrong number of arguments (given 1, expected 0)

(byebug) method(__method__).super_method.call
*** ArgumentError Exception: wrong number of arguments (given 0, expected 1)

(byebug) method(__method__).super_method.call({})
nil
It has an arity of 1 but I can’t send it an argument if I invoke it via super
but as a method object it fails unless I pass it an argument
:astonished:
John Backus
@backus
Apr 30 2016 04:21
Wow wtf
Source?
Tim Riley
@timriley
Apr 30 2016 04:22
AFAICT, this is the super:
    let(:parent_class) do
      Class.new do
        include Test::AutoInject.hash[:one, :two, 'namespace.three']

        attr_reader :other

        def initialize(options)
          @other = options[:other]
          super
        end
      end
    end
(I’m working on getting inheritance to work better with dry-auto_inject)
but my breakpoint is inside AutoInject’s generated #initialize
which is technically inside an ancestor module to that parent class
hmmm
I think perhaps super_method is misleading me a little here.
Tim Riley
@timriley
Apr 30 2016 04:54
Yep, it was super_method not helping me out.
Tim Riley
@timriley
Apr 30 2016 06:12
irb(main):015:0> def foo(bar: nil)
irb(main):016:1> end
=> nil
irb(main):017:0> method(:foo)
=> #<Method: Object#foo>
irb(main):018:0> method(:foo).arity
=> 0
Thanks for nothing, Ruby 2.0
timriley @timriley investigates Method#parameters instead
Tim Riley
@timriley
Apr 30 2016 07:04
That fixes it!
Christopher Dennl-Ortega Arrieta
@cdennl
Apr 30 2016 07:13
@Bounga with i18n it is merged
no need to recreate the whole file
Nikita Shilnikov
@flash-gordon
Apr 30 2016 07:16
@timriley wow, cool. I think I have a PR for dry-container
because
2.3.0 :001 > (-> * {}).arity
 => -1
2.3.0 :002 > (-> ** {}).arity
 => -1
2.3.0 :003 > (proc { |*| }).arity
 => -1
2.3.0 :004 > (proc { |**| }).arity
 => 0
Tim Riley
@timriley
Apr 30 2016 08:15
@flash-gordon ah, nice find. Yeah, I think #parameters is a much more reliable way to check. Especially because if all you’re doing is checking for 0, you can just use item.parameters.empty?
Nicolas Cavigneaux
@Bounga
Apr 30 2016 08:42
@solnic No I don"t but I can, I'm going to take a look at it
Piotr Solnica
@solnic
Apr 30 2016 08:44
@Bounga it is not needed. Just asking. Yaml will merge custom errors into defaults anyway. So no. No need to copy everything
Nicolas Cavigneaux
@Bounga
Apr 30 2016 08:46
nice!
Piotr Solnica
@solnic
Apr 30 2016 10:59
@coop are you planning to extract attr DSL to a separate gem? I just realized this is gonna block 0.8.0 release, unless we just decide to say "attr" is gone for now, sorry
Nikita Shilnikov
@flash-gordon
Apr 30 2016 20:31
@solnic :+1: see you
Tim Riley
@timriley
Apr 30 2016 21:43
:wave: