Skip to content

Commit e76c561

Browse files
committed
fixed hyperspec event handling
1 parent babeaa0 commit e76c561

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

ruby/hyper-component/lib/hyperstack/internal/component/class_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def raises(name, opts = {})
131131
aka = opts[:alias] || "#{name}!"
132132
name = name =~ /^<(.+)>$/ ? name.gsub(/^<(.+)>$/, '\1') : "on_#{name}"
133133
validator.event(name)
134-
define_method(aka) { props[name]&.call }
134+
define_method(aka) { |*args| props[name]&.call(*args) }
135135
end
136136

137137
def define_state(*states, &block)

ruby/hyper-component/lib/hyperstack/internal/component/validator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def optional(name, options = {})
3939
end
4040

4141
def event(name)
42-
rules[name] = coerce_native_hash_values(default: nil)
42+
rules[name] = coerce_native_hash_values(default: nil, type: Proc)
4343
end
4444

4545
def all_other_params(name)

ruby/hyper-spec/lib/sources/top_level_rails_component.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ def clear_callback_history_for(proc_name)
2424
end
2525

2626
def event_history_for(event_name)
27-
event_history["_on#{event_name.event_camelize}"]
27+
event_history["on_#{event_name}"]
2828
end
2929

3030
def last_event_for(event_name)
31-
event_history["_on#{event_name.event_camelize}"].last
31+
event_history["on_#{event_name}"].last
3232
end
3333

3434
def clear_event_history_for(event_name)
35-
event_history["_on#{event_name.event_camelize}"] = []
35+
event_history["on_#{event_name}"] = []
3636
end
3737
end
3838

ruby/hyper-spec/spec/hyper_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ class CallBackOnEveryThirdClick
109109
include Hyperstack::Component
110110
include Hyperstack::State::Observable
111111
param :click3, type: Proc
112-
param :_onClick3, type: Proc
112+
raises :click3
113113
before_mount { @clicks = 0 }
114114
def increment_click
115115
mutate @clicks += 1
116116
if @clicks % 3 == 0
117-
@click3.call(@clicks)
118-
@_onClick3.call(@clicks)
117+
@Click3.call(@clicks)
118+
click3!(@clicks)
119119
end
120120
end
121121
render do

ruby/hyper-spec/spec/test_app/app/views/components/say_hello.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ class SayHello
22
include Hyperstack::Component
33
param :name
44
render(DIV) do
5-
"Hello there #{@name}"
5+
"Hello there #{@Name}"
66
end
77
end

0 commit comments

Comments
 (0)