Skip to content

Commit

Permalink
fix kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
tycooon committed Jun 18, 2021
1 parent b660b3b commit 74fea1e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ GEM

PLATFORMS
x86_64-darwin-19
x86_64-darwin-20
x86_64-linux

DEPENDENCIES
Expand All @@ -132,4 +133,4 @@ DEPENDENCIES
simplecov-lcov

BUNDLED WITH
2.2.15
2.2.17
8 changes: 4 additions & 4 deletions lib/resol/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ def self.included(base)
end

module ClassMethods
def build_klass(*args)
def build_klass(*args, **kwargs)
klass = self

loop do
new_klass = klass.build!(klass, *args)
new_klass = klass.build!(klass, *args, **kwargs)
break if new_klass == klass

klass = new_klass
Expand All @@ -21,8 +21,8 @@ def build_klass(*args)
klass
end

def build(*args)
build_klass(*args).new(*args)
def build(*args, **kwargs)
build_klass(*args, **kwargs).new(*args, **kwargs)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/resol/callbacks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def before_call(method_name)
private

def __run_callbacks__(instance)
@__callback_methods__.each { |method_name| instance.send(method_name) }
@__callback_methods__.each { |method_name| instance.__send__(method_name) }
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/resol/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def value!
end
end

def self.Success(*args)
Success.new(*args)
def self.Success(...)
Success.new(...)
end

def self.Failure(*args)
Failure.new(*args)
def self.Failure(...)
Failure.new(...)
end
end
8 changes: 4 additions & 4 deletions lib/resol/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def inherited(klass)
super
end

def call(*args, &block)
command = build(*args)
def call(*args, **kwargs, &block)
command = build(*args, **kwargs)
__run_callbacks__(command)
command.call(&block)

Expand All @@ -64,8 +64,8 @@ def call(*args, &block)
Resol::Failure(e)
end

def call!(*args)
call(*args).value_or { |error| raise error }
def call!(*args, **kwargs)
call(*args, **kwargs).value_or { |error| raise error }
end
end

Expand Down

0 comments on commit 74fea1e

Please sign in to comment.