Skip to content

Commit

Permalink
Merge pull request #22 from HolyWalley/feature/make-it-compatible-wit…
Browse files Browse the repository at this point in the history
…h-ruby-3

Add support for ruby 3+
  • Loading branch information
nepalez authored Jun 18, 2022
2 parents 674a2bd + 56ae91d commit a191f22
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/tram/policy/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module DSL
# @return [self]
#
def validate(name = nil, **opts, &block)
local_validators << Validator.new(name, block, opts)
local_validators << Validator.new(name, block, **opts)
self
end

Expand Down
2 changes: 1 addition & 1 deletion lib/tram/policy/error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def item
# @return [String]
#
def message
key.is_a?(Symbol) ? I18n.t(*item) : key.to_s
key.is_a?(Symbol) ? I18n.t(key, **tags) : key.to_s
end

# Fetches an option
Expand Down
4 changes: 2 additions & 2 deletions lib/tram/policy/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def each
#
def filter(key = nil, **tags)
list = each_with_object(Set.new) do |error, obj|
obj << error if error.contain?(key, tags)
obj << error if error.contain?(key, **tags)
end
self.class.new(scope: scope, errors: list)
end
Expand Down Expand Up @@ -95,7 +95,7 @@ def merge(other, **options)
other.each do |err|
key, opts = err.item
opts = yield(opts) if block_given?
add key, opts.merge(options)
add key, **opts.merge(options)
end

self
Expand Down
2 changes: 1 addition & 1 deletion lib/tram/policy/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def locales
end

def check(policy, tags)
@errors ||= policy.errors.filter(tags).map do |error|
@errors ||= policy.errors.filter(**tags).map do |error|
{ item: error.item }.tap do |obj|
locales.each { |l| obj[l] = I18n.with_locale(l) { error.message } }
end
Expand Down
2 changes: 1 addition & 1 deletion spec/tram/policy/error_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
RSpec.describe Tram::Policy::Error do
subject(:error) { described_class.new :bad, options }
subject(:error) { described_class.new :bad, **options }

let(:scope) { %w[tram-policy] }
let(:options) { { level: "warning", scope: scope } }
Expand Down

0 comments on commit a191f22

Please sign in to comment.