hyper-react 0.12.4 → 0.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d78da47b440564ff0600124d3ad69ce7a97a209
4
- data.tar.gz: 450577e039563cce562ee19f99507bbc15094058
3
+ metadata.gz: c9dfd2ede4b7075ebde96ad71adf1aaab43da3a7
4
+ data.tar.gz: c54255fffa202f06f973a7cab47650f964756137
5
5
  SHA512:
6
- metadata.gz: e01176000b613dcecc56da174ea7d6e7ca7e055256cb8f3cf036e986204f91e9ae0e942851542a72d0cd0be2bd0b987aab615aa77a7b1cea3c604dcef8664183
7
- data.tar.gz: a15cdadf67c66cc76011bb08d1c5d55ee76e75ee8865a676c07004c9d9bfe42b522201c76041c45498da1d68f8d9fd2d6a31cf2337f5418002d6b9a251c058dc
6
+ metadata.gz: e23e0f4a3990f7120830c44dad97cc33f6e4bf3f7f50f8e9e84f59263f89f1767d32cc4b556198500fd3bb3e3d209e68fcf8740d3bb59802fad1334e381831db
7
+ data.tar.gz: 6c7eb1b35bfe2bb9181e61c3fba07db3cef4e060b6e8785a93df61f74b6edf24ddedef6867af9e6d911d55489c3fada9026a68c9b373c2339d492c7353cebe99
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'opal', '>= 0.8.0'
22
22
  s.add_dependency 'opal-activesupport', '>= 0.2.0'
23
23
  s.add_dependency 'hyper-store', '>= 0.2.1'
24
- s.add_dependency 'hyperloop-config', '>= 0.9.2'
24
+ s.add_dependency 'hyperloop-config', '>= 0.9.7'
25
25
  s.add_development_dependency 'rake', '< 11.0'
26
26
  s.add_development_dependency 'rspec-rails', '3.3.3'
27
27
  s.add_development_dependency 'timecop'
@@ -1,5 +1,5 @@
1
- require 'active_support/core_ext/class/attribute'
2
-
1
+ require 'hyperloop-config'
2
+ Hyperloop::Context
3
3
  module React
4
4
  module Callbacks
5
5
  def self.included(base)
@@ -18,24 +18,23 @@ module React
18
18
 
19
19
  module ClassMethods
20
20
  def define_callback(callback_name)
21
- attribute_name = "_#{callback_name}_callbacks"
22
- class_attribute(attribute_name)
23
- self.send("#{attribute_name}=", [])
21
+ wrapper_name = "_#{callback_name}_callbacks"
22
+ define_singleton_method(wrapper_name) do
23
+ Hyperloop::Context.set_var(self, "@#{wrapper_name}", force: true) { [] }
24
+ end
24
25
  define_singleton_method(callback_name) do |*args, &block|
25
- callbacks = self.send(attribute_name)
26
- callbacks.concat(args)
27
- callbacks.push(block) if block_given?
28
- self.send("#{attribute_name}=", callbacks)
26
+ send(wrapper_name).concat(args)
27
+ send(wrapper_name).push(block) if block_given?
29
28
  end
30
29
  end
31
30
 
32
31
  def callbacks_for(callback_name)
33
- attribute_name = "_#{callback_name}_callbacks"
32
+ wrapper_name = "_#{callback_name}_callbacks"
34
33
  if superclass.respond_to? :callbacks_for
35
34
  superclass.callbacks_for(callback_name)
36
35
  else
37
36
  []
38
- end + self.send(attribute_name)
37
+ end + send(wrapper_name)
39
38
  end
40
39
  end
41
40
  end
@@ -1,3 +1,3 @@
1
1
  module React
2
- VERSION = "0.12.4"
2
+ VERSION = "0.12.5"
3
3
  end
@@ -24,19 +24,50 @@ describe React::Callbacks do
24
24
  include React::Callbacks
25
25
  define_callback :before_dinner
26
26
 
27
- before_dinner :wash_hand, :turn_of_laptop
27
+ before_dinner :wash_hand, :turn_off_laptop
28
28
 
29
29
  def wash_hand;end
30
30
 
31
- def turn_of_laptop;end
31
+ def turn_off_laptop;end
32
32
  end
33
33
 
34
34
  instance = Foo.new
35
35
  expect(instance).to receive(:wash_hand)
36
- expect(instance).to receive(:turn_of_laptop)
36
+ expect(instance).to receive(:turn_off_laptop)
37
37
  instance.run_callback(:before_dinner)
38
38
  end
39
39
 
40
+ context 'using Hyperloop::Context.reset!' do
41
+ after(:all) do
42
+ Hyperloop::Context.instance_variable_set(:@context, nil)
43
+ end
44
+ it 'clears callbacks on Hyperloop::Context.reset!' do
45
+ Hyperloop::Context.reset!
46
+ stub_const 'Foo', Class.new
47
+ Foo.class_eval do
48
+ include React::Callbacks
49
+ define_callback :before_dinner
50
+
51
+ before_dinner :wash_hand, :turn_off_laptop
52
+
53
+ def wash_hands;end
54
+
55
+ def turn_off_laptop;end
56
+ end
57
+ instance = Foo.new
58
+ expect(instance).to receive(:wash_hand).once
59
+ expect(instance).not_to receive(:turn_off_laptop)
60
+
61
+ Hyperloop::Context.reset!
62
+
63
+ instance.run_callback(:before_dinner)
64
+ Foo.class_eval do
65
+ before_dinner :wash_hand
66
+ end
67
+ instance.run_callback(:before_dinner)
68
+ end
69
+ end # moved elswhere cause its just hard to get anything to work in this environment
70
+
40
71
  it 'defines block callback' do
41
72
  stub_const 'Foo', Class.new
42
73
  Foo.class_eval do
@@ -15,6 +15,8 @@ end
15
15
 
16
16
  if RUBY_ENGINE == 'opal'
17
17
  require File.expand_path('../vendor/jquery-2.2.4.min', __FILE__)
18
+ require 'hyperloop-config'
19
+ Hyperloop::Context
18
20
  require 'react/react-source-browser'
19
21
  require 'react/react-source-server'
20
22
  require 'hyper-react'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyper-react
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.4
4
+ version: 0.12.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chang
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-24 00:00:00.000000000 Z
13
+ date: 2017-03-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: opal
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - ">="
62
62
  - !ruby/object:Gem::Version
63
- version: 0.9.2
63
+ version: 0.9.7
64
64
  type: :runtime
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="
69
69
  - !ruby/object:Gem::Version
70
- version: 0.9.2
70
+ version: 0.9.7
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: rake
73
73
  requirement: !ruby/object:Gem::Requirement