Skip to content

Commit

Permalink
Use kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
cllns committed Jul 15, 2024
1 parent a43da88 commit e9ce05a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/dry/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def initialize(attributes)
# rom_n_roda[:title] #=> 'Web Development with ROM and Roda'
# rom_n_roda[:subtitle] #=> nil
def [](name)
@attributes.fetch(name) { raise MissingAttributeError, {name: name, klass: self.class} }
@attributes.fetch(name) { raise MissingAttributeError.new(attribute: name, klass: self.class) }
end

# Converts the {Dry::Struct} to a hash with keys representing
Expand Down
4 changes: 2 additions & 2 deletions lib/dry/struct/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ def initialize(key)

# Raised when a struct doesn't have an attribute
class MissingAttributeError < ::KeyError
def initialize(data)
super("Missing attribute: #{data[:name].inspect} on #{data[:klass]}")
def initialize(attribute:, klass:)
super("Missing attribute: #{attribute.inspect} on #{klass}")
end
end

Expand Down

0 comments on commit e9ce05a

Please sign in to comment.