Skip to content

2.4.0.rc4 'ArgumentError: unknown keywords' when using keywords args w/unified lambda args #166

@davidcpell

Description

@davidcpell

Loving 2.4 so far! Today I ran into an issue with the keyword args option for lambdas:

Using this per the blog example:

  property :team_id, 
    as: :teamId, 
    setter: ->(fragment:, doc:) { puts "#{fragment}" }

...raises the following exception:

ArgumentError:         ArgumentError: unknown keywords: options, represented, decorator, binding, input, as, user_options

If I add more keyword args (e.g. decorator:), that arg disappears from the error list. Likewise if I take keyword args away, they appear in the error list. It seems as if I'm being expected to either pass a singular variable 'options' or every single keyword possible variable.

Using options:

  property :team_id, 
    as: :teamId, 
    setter: ->(options) { puts options[:doc] }

...works without raising any exceptions.

So far I've had to resort to the old positional args to get the desired behavior:

  property :team, 
    as: :teamId, 
    setter: ->(val, *) do 
      self.team = team_model.stats_find(val)
    end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions