Skip to content

Commit a615ef4

Browse files
committed
added toggle method and moved legacy state to be state variable module
1 parent f5c3f69 commit a615ef4

File tree

28 files changed

+141
-121
lines changed

28 files changed

+141
-121
lines changed

.travis.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ cache:
44
directories:
55
- node_modules # NPM packages
66
env:
7-
# - COMPONENT=hyper-component LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
8-
# #- COMPONENT=hyper-console LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
9-
# - COMPONENT=hyper-i18n LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
10-
# - COMPONENT=hyper-model LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
11-
# - COMPONENT=hyper-operation LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
12-
# - COMPONENT=hyper-router LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
13-
# - COMPONENT=hyper-spec LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
14-
# - COMPONENT=hyper-state LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
15-
# - COMPONENT=hyper-store LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
7+
- COMPONENT=hyper-component LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
8+
#- COMPONENT=hyper-console LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
9+
- COMPONENT=hyper-i18n LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
10+
- COMPONENT=hyper-model LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
11+
- COMPONENT=hyper-operation LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
12+
- COMPONENT=hyper-router LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
13+
- COMPONENT=hyper-spec LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
14+
- COMPONENT=hyper-state LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
15+
- COMPONENT=hyper-store LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
1616
- COMPONENT=hyper-trace LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
17-
# - COMPONENT=rails-hyperstack LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
18-
# - COMPONENT=hyperstack-config LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
17+
- COMPONENT=rails-hyperstack LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
18+
- COMPONENT=hyperstack-config LANGUAGE=ruby LANGUAGE_VERSION=2.5.1
1919
jobs:
2020
include:
2121
- stage: test
@@ -52,7 +52,7 @@ jobs:
5252
before_script:
5353
- cd $LANGUAGE/$COMPONENT
5454
script:
55-
- echo deploying $COMPONENT
55+
- echo deploying $COMPONENT
5656
deploy:
5757
- provider: rubygems
5858
api_key:

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ def props
2323
Hash.new(`#{@__hyperstack_component_native}.props`)
2424
end
2525

26-
def refs
27-
Hash.new(`#{@__hyperstack_component_native}.refs`)
28-
end
29-
3026
def dom_node
3127
`ReactDOM.findDOMNode(#{self}.__hyperstack_component_native)` # react >= v0.15.0
3228
end

ruby/hyper-component/spec/spec_helper.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,26 +55,26 @@ class JavaScriptError < StandardError; end
5555
end
5656

5757
# Stubbing the React calls so we can test outside of Opal
58-
module React
59-
class State
60-
class << self
61-
def reset!
62-
@states = nil
63-
end
64-
65-
def get_state(from, key)
66-
states[from] ||= {}
67-
states[from][key.to_s]
68-
end
69-
70-
def set_state(from, key, value)
71-
states[from] ||= {}
72-
states[from][key.to_s] = value
73-
end
74-
75-
def states
76-
@states ||= {}
77-
end
78-
end
79-
end
80-
end
58+
# module React
59+
# class State
60+
# class << self
61+
# def reset!
62+
# @states = nil
63+
# end
64+
#
65+
# def get_state(from, key)
66+
# states[from] ||= {}
67+
# states[from][key.to_s]
68+
# end
69+
#
70+
# def set_state(from, key, value)
71+
# states[from] ||= {}
72+
# states[from][key.to_s] = value
73+
# end
74+
#
75+
# def states
76+
# @states ||= {}
77+
# end
78+
# end
79+
# end
80+
# end

ruby/hyper-model/Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ source 'https://rubygems.org'
44
#gem 'hyper-spec', path: '../hyper-spec'
55
gem 'hyperstack-config', path: '../hyperstack-config'
66
gem 'hyper-state', path: '../hyper-state'
7-
gem 'hyper-store', path: '../hyper-store'
87
gem 'hyper-component', path: '../hyper-component'
98
gem 'hyper-operation', path: '../hyper-operation'
109

ruby/hyper-model/Gemfile.lock

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
PATH
22
remote: ../hyper-component
33
specs:
4-
hyper-component (0.1)
5-
hyper-state (= 0.1)
6-
hyperstack-config (= 0.1)
4+
hyper-component (1.0.alpha1.1)
5+
hyper-state (= 1.0.alpha1.1)
6+
hyperstack-config (= 1.0.alpha1.1)
77
libv8 (~> 6.3.0)
88
mini_racer (~> 0.1.15)
99
opal (>= 0.11.0, < 0.12.0)
@@ -13,31 +13,23 @@ PATH
1313
PATH
1414
remote: ../hyper-operation
1515
specs:
16-
hyper-operation (0.1)
16+
hyper-operation (1.0.alpha1.1)
1717
activerecord (>= 4.0.0)
18-
hyper-component (= 0.1)
18+
hyper-component (= 1.0.alpha1.1)
1919
mutations
2020
opal-activesupport (~> 0.3.1)
2121

2222
PATH
2323
remote: ../hyper-state
2424
specs:
25-
hyper-state (0.1)
26-
hyperstack-config (= 0.1)
27-
opal (>= 0.11.0, < 0.12.0)
28-
29-
PATH
30-
remote: ../hyper-store
31-
specs:
32-
hyper-store (0.1)
33-
hyper-state (= 0.1)
34-
hyperstack-config (= 0.1)
25+
hyper-state (1.0.alpha1.1)
26+
hyperstack-config (= 1.0.alpha1.1)
3527
opal (>= 0.11.0, < 0.12.0)
3628

3729
PATH
3830
remote: ../hyperstack-config
3931
specs:
40-
hyperstack-config (0.1)
32+
hyperstack-config (1.0.alpha1.1)
4133
libv8 (~> 6.3.0)
4234
listen (~> 3.0)
4335
mini_racer (~> 0.1.15)
@@ -49,12 +41,11 @@ PATH
4941
PATH
5042
remote: .
5143
specs:
52-
hyper-model (0.1)
44+
hyper-model (1.0.alpha1.1)
5345
activemodel
5446
activerecord (>= 4.0.0)
55-
hyper-component (= 0.1)
56-
hyper-operation (= 0.1)
57-
hyper-store (= 0.1)
47+
hyper-component (= 1.0.alpha1.1)
48+
hyper-operation (= 1.0.alpha1.1)
5849

5950
GEM
6051
remote: https://rubygems.org/
@@ -393,7 +384,6 @@ DEPENDENCIES
393384
hyper-model!
394385
hyper-operation!
395386
hyper-state!
396-
hyper-store!
397387
hyperstack-config!
398388
libv8 (~> 6.3.0)
399389
mini_racer (~> 0.1.15)

ruby/hyper-model/hyper-model.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Gem::Specification.new do |spec|
2929
spec.add_dependency 'activerecord', '>= 4.0.0'
3030
spec.add_dependency 'hyper-component', HyperModel::VERSION
3131
spec.add_dependency 'hyper-operation', HyperModel::VERSION
32-
spec.add_dependency 'hyper-store', HyperModel::VERSION # only for Hyperstack::Internal::Store::State which should be moved
3332
spec.add_development_dependency 'bundler'
3433
spec.add_development_dependency 'capybara'
3534
spec.add_development_dependency 'chromedriver-helper', '1.2.0'

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
require 'object/tap'
1111
require 'active_model_client_stubs'
1212
require 'hyper-state'
13-
require 'hyper-store'
1413
require "reactive_record/active_record_error"
1514
require "reactive_record/active_record/errors"
1615
require "reactive_record/active_record/error"

ruby/hyper-model/lib/reactive_record/active_record/errors.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def empty?
210210
alias :blank? :empty?
211211

212212
def reactive_empty?
213-
Hyperstack::Internal::Store::State.get_state(self, 'ERRORS?')
213+
Hyperstack::Internal::State::Variable.get(self, 'ERRORS?')
214214
end
215215

216216
# Clear the error messages.
@@ -368,7 +368,7 @@ def without_default_proc(hash)
368368
end
369369

370370
def reactive_empty!(state = empty?)
371-
Hyperstack::Internal::Store::State.set_state(self, 'ERRORS?', state) unless ReactiveRecord::Base.data_loading?
371+
Hyperstack::Internal::State::Variable.set(self, 'ERRORS?', state) unless ReactiveRecord::Base.data_loading?
372372
end
373373
end
374374
end

ruby/hyper-model/lib/reactive_record/active_record/instance_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def new?
149149
end
150150

151151
def errors
152-
Hyperstack::Internal::Store::State.get_state(@backing_record, @backing_record)
152+
Hyperstack::Internal::State::Variable.get(@backing_record, @backing_record)
153153
@backing_record.errors
154154
end
155155

ruby/hyper-model/lib/reactive_record/active_record/reactive_record/base.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ def id=(value)
180180

181181
def changed?(*args)
182182
if args.count == 0
183-
Hyperstack::Internal::Store::State.get_state(self, "!CHANGED!")
183+
Hyperstack::Internal::State::Variable.get(self, "!CHANGED!")
184184
!changed_attributes.empty?
185185
else
186-
Hyperstack::Internal::Store::State.get_state(self, args[0])
186+
Hyperstack::Internal::State::Variable.get(self, args[0])
187187
changed_attributes.include? args[0]
188188
end
189189
end
@@ -288,7 +288,7 @@ def revert
288288
end
289289

290290
def saving!
291-
Hyperstack::Internal::Store::State.set_state(self, self, :saving) unless data_loading?
291+
Hyperstack::Internal::State::Variable.set(self, self, :saving) unless data_loading?
292292
@saving = true
293293
end
294294

@@ -306,9 +306,9 @@ def saved!(save_only = nil) # sets saving to false AND notifies
306306
notify_waiting_for_save
307307
return self if save_only
308308
if errors.empty?
309-
Hyperstack::Internal::Store::State.set_state(self, self, :saved)
309+
Hyperstack::Internal::State::Variable.set(self, self, :saved)
310310
elsif !data_loading?
311-
Hyperstack::Internal::Store::State.set_state(self, self, :error)
311+
Hyperstack::Internal::State::Variable.set(self, self, :error)
312312
end
313313
self
314314
end
@@ -334,7 +334,7 @@ def self.notify_waiting_for_save(model)
334334
end
335335

336336
def saving?
337-
Hyperstack::Internal::Store::State.get_state(self, self)
337+
Hyperstack::Internal::State::Variable.get(self, self)
338338
@saving
339339
end
340340

0 commit comments

Comments
 (0)