Skip to content

Commit 81c8730

Browse files
committed
fix arity for activerecord relations
1 parent d8e85aa commit 81c8730

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

ruby/hyper-model/lib/active_record_base.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,23 +286,23 @@ def regulate_relationship(name, &block)
286286

287287
alias pre_syncromesh_has_many has_many
288288

289-
def has_many(name, *args, &block)
289+
def has_many(name,*args, **kwargs, &block)
290290
__synchromesh_regulate_from_macro(
291-
opts = args.extract_options!,
291+
kwargs,# opts = args.extract_options!,
292292
name,
293293
method_defined?(:"__secure_remote_access_to_#{name}"),
294294
&method(:regulate_relationship)
295295
)
296-
pre_syncromesh_has_many name, *args, opts.except(:regulate), &block
296+
pre_syncromesh_has_many name, *args, **kwargs.except(:regulate), &block
297297
end
298298

299299
%i[belongs_to has_one composed_of].each do |macro|
300300
alias_method :"pre_syncromesh_#{macro}", macro
301-
define_method(macro) do |name, *aargs, &block|
302-
define_method(:"__secure_remote_access_to_#{name}") do |this, _acting_user, *args|
303-
this.send(name, *args)
301+
define_method(macro) do |name, **aargs, &block|
302+
define_method(:"__secure_remote_access_to_#{name}") do |this, _acting_user, **args|
303+
this.send(name, **args)
304304
end
305-
send(:"pre_syncromesh_#{macro}", name, *aargs, &block)
305+
send(:"pre_syncromesh_#{macro}", name, **aargs, &block)
306306
end
307307
end
308308
end

ruby/hyper-model/lib/reactive_record/permissions.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ class << self
7474
attr_reader :reactive_record_association_keys
7575

7676
[:has_many, :belongs_to, :composed_of].each do |macro|
77-
define_method "#{macro}_with_reactive_record_add_changed_method".to_sym do |attr_name, *args, &block|
77+
define_method "#{macro}_with_reactive_record_add_changed_method".to_sym do |attr_name, *args, **kwargs, &block|
7878
define_method "#{attr_name}_changed?".to_sym do
7979
instance_variable_get "@reactive_record_#{attr_name}_changed".to_sym
8080
end
8181
(@reactive_record_association_keys ||= []) << attr_name
82-
send "#{macro}_without_reactive_record_add_changed_method".to_sym, attr_name, *args, &block
82+
send "#{macro}_without_reactive_record_add_changed_method".to_sym, attr_name, *args, **kwargs, &block
8383
end
8484
alias_method "#{macro}_without_reactive_record_add_changed_method".to_sym, macro
8585
alias_method macro, "#{macro}_with_reactive_record_add_changed_method".to_sym
8686
end
8787

8888
alias belongs_to_without_reactive_record_add_is_method belongs_to
8989

90-
def belongs_to(attr_name, *args)
91-
belongs_to_without_reactive_record_add_is_method(attr_name, *args).tap do
90+
def belongs_to(attr_name,*args,**kwargs)
91+
belongs_to_without_reactive_record_add_is_method(attr_name, *args, **kwargs).tap do
9292
define_method "#{attr_name}_is?".to_sym do |model|
9393
attributes[self.class.reflections[attr_name.to_s].foreign_key] == model.id
9494
end

0 commit comments

Comments
 (0)