79534569

Date: 2025-03-25 18:35:53
Score: 1.5
Natty:
Report link

I'm new to Ruby, but some things have changed since this question was asked: https://blog.saeloun.com/2019/10/07/ruby-2-7-keyword-arguments-redesign/. For a constructor like this:

def initialize(channel_id:, token:)
  @channel_id = channel_id
  @bot_token = token
end

...I need this kind of code to populate a new instance from entries in config.yml:

        case entry['type']
        when 'my'
          # Invalid keys will cause an exception.
          args = destination.transform_keys(&:to_sym)
          args.delete(:type)
          slack = MyClass.new(**args)
Reasons:
  • Blacklisted phrase (0.5): I need
  • RegEx Blacklisted phrase (1.5): I'm new
  • Has code block (-0.5):
Posted by: AbuNassar