Skip to content

Commit 37947b3

Browse files
committed
added :none naming_convention and moved it to Hyperstack module
1 parent 2fa42dc commit 37947b3

File tree

5 files changed

+34
-37
lines changed

5 files changed

+34
-37
lines changed

ruby/examples/misc/stock-tickers/app/hyperstack/components/hyper_component.rb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
module Hyperstack
2-
module State
3-
module Observable
4-
def self.naming_convention
5-
:prefix_params
6-
end
7-
end
8-
end
1+
def Hyperstack.naming_convention
2+
:prefix_params
93
end
104

115
class HyperComponent

ruby/hyper-component/Gemfile.lock

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: ../hyper-spec
33
specs:
4-
hyper-spec (0.1)
4+
hyper-spec (1.0.rc1)
55
capybara
66
chromedriver-helper (= 1.2.0)
77
libv8 (~> 6.3.0)
@@ -20,22 +20,22 @@ PATH
2020
PATH
2121
remote: ../hyper-state
2222
specs:
23-
hyper-state (0.1)
24-
hyperstack-config (= 0.1)
23+
hyper-state (1.0.rc1)
24+
hyperstack-config (= 1.0.rc1)
2525
opal (>= 0.11.0, < 0.12.0)
2626

2727
PATH
2828
remote: ../hyper-store
2929
specs:
30-
hyper-store (0.1)
31-
hyper-state (= 0.1)
32-
hyperstack-config (= 0.1)
30+
hyper-store (1.0.rc1)
31+
hyper-state (= 1.0.rc1)
32+
hyperstack-config (= 1.0.rc1)
3333
opal (>= 0.11.0, < 0.12.0)
3434

3535
PATH
3636
remote: ../hyperstack-config
3737
specs:
38-
hyperstack-config (0.1)
38+
hyperstack-config (1.0.rc1)
3939
libv8 (~> 6.3.0)
4040
listen (~> 3.0)
4141
mini_racer (~> 0.1.15)
@@ -47,9 +47,9 @@ PATH
4747
PATH
4848
remote: .
4949
specs:
50-
hyper-component (0.1)
51-
hyper-state (= 0.1)
52-
hyperstack-config (= 0.1)
50+
hyper-component (1.0.rc1)
51+
hyper-state (= 1.0.rc1)
52+
hyperstack-config (= 1.0.rc1)
5353
libv8 (~> 6.3.0)
5454
mini_racer (~> 0.1.15)
5555
opal (>= 0.11.0, < 0.12.0)
@@ -115,13 +115,14 @@ GEM
115115
babel-source (>= 4.0, < 6)
116116
execjs (~> 2.0)
117117
builder (3.2.3)
118-
capybara (3.9.0)
118+
capybara (3.10.1)
119119
addressable
120120
mini_mime (>= 0.1.3)
121121
nokogiri (~> 1.8)
122122
rack (>= 1.6.0)
123123
rack-test (>= 0.6.3)
124-
xpath (~> 3.1)
124+
regexp_parser (~> 1.2)
125+
xpath (~> 3.2)
125126
childprocess (0.9.0)
126127
ffi (~> 1.0, >= 1.0.11)
127128
chromedriver-helper (1.2.0)
@@ -151,7 +152,7 @@ GEM
151152
rails-dom-testing (>= 1, < 3)
152153
railties (>= 4.2.0)
153154
thor (>= 0.14, < 2.0)
154-
libv8 (6.3.292.48.1)
155+
libv8 (6.3.292.48.1-x86_64-darwin-15)
155156
listen (3.1.5)
156157
rb-fsevent (~> 0.9, >= 0.9.4)
157158
rb-inotify (~> 0.9, >= 0.9.7)
@@ -261,6 +262,7 @@ GEM
261262
execjs
262263
railties (>= 3.2)
263264
tilt
265+
regexp_parser (1.2.0)
264266
rspec-core (3.8.0)
265267
rspec-support (~> 3.8.0)
266268
rspec-expectations (3.8.2)
@@ -288,7 +290,7 @@ GEM
288290
ruby-progressbar (1.10.0)
289291
ruby_dep (1.5.0)
290292
rubyzip (1.2.2)
291-
selenium-webdriver (3.14.1)
293+
selenium-webdriver (3.141.0)
292294
childprocess (~> 0.5)
293295
rubyzip (~> 1.2, >= 1.2.2)
294296
sourcemap (0.1.1)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class PropsWrapper
77

88
class << self
99
def instance_var_name_for(name)
10-
case Hyperstack::State::Observable.naming_convention
10+
case Hyperstack.naming_convention
1111
when :camelize_params
1212
name.camelize
1313
when :prefix_params

ruby/hyper-state/lib/hyperstack/state/observable.rb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ def self.bulk_update(&block)
55
Internal::State::Mapper.bulk_update(&block)
66
end
77

8-
def self.naming_convention
9-
:camelize_params
10-
end
11-
128
def self.included(base)
139
base.include Internal::AutoUnmount
1410
%i[singleton_method method].each do |kind|
@@ -28,26 +24,26 @@ def self.included(base)
2824
end
2925
if RUBY_ENGINE == 'opal'
3026
base.send(:"define_#{kind}", :set) do |var|
31-
if Hyperstack::State::Observable.naming_convention == :prefix_state
27+
if Hyperstack.naming_convention == :prefix_state
3228
var = "_#{var}" if var !~ /^_/
33-
elsif var =~ /^[a-z]/
34-
add_mutate = true
29+
elsif Hyperstack.naming_convention != :none && var !~ /^[a-z]/
30+
dont_mutate = true
3531
end
3632
lambda do |val|
3733
`self[#{var}] = #{val}`
38-
mutate if add_mutate
34+
mutate unless dont_mutate
3935
end
4036
end
4137
else
4238
base.send(:"define_#{kind}", :set) do |var|
43-
if Hyperstack::State::Observable.naming_convention == :prefix_state
39+
if Hyperstack.naming_convention == :prefix_state
4440
var = "_#{var}" if var !~ /^_/
45-
elsif var =~ /^[a-z]/
46-
add_mutate = true
41+
elsif Hyperstack.naming_convention != :none && var !~ /^[a-z]/
42+
dont_mutate = true
4743
end
4844
lambda do |val|
4945
instance_variable_set(:"@#{var}", val)
50-
mutate if add_mutate
46+
mutate unless dont_mutate
5147
end
5248
end
5349
end
@@ -67,7 +63,7 @@ def self.included(base)
6763
end
6864
base.singleton_class.send(:"define_#{kind}", :state_reader) do |*names|
6965
names.each do |name|
70-
var_name = if Hyperstack::State::Observable.naming_convention == :prefix_state && name !~ /^_/
66+
var_name = if Hyperstack.naming_convention == :prefix_state && name !~ /^_/
7167
"_#{name}"
7268
else
7369
name
@@ -79,7 +75,7 @@ def self.included(base)
7975
end
8076
base.singleton_class.send(:"define_#{kind}", :state_writer) do |*names|
8177
names.each do |name|
82-
var_name = if Hyperstack::State::Observable.naming_convention == :prefix_state && name !~ /^_/
78+
var_name = if Hyperstack.naming_convention == :prefix_state && name !~ /^_/
8379
"_#{name}"
8480
else
8581
name

ruby/hyperstack-config/lib/hyperstack-config.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
require 'hyperstack/boot'
2+
module Hyperstack
3+
def self.naming_convention
4+
:camelize_params
5+
end
6+
end
27
if RUBY_ENGINE == 'opal'
38
require 'hyperstack/deprecation_warning'
49
require 'hyperstack/string'

0 commit comments

Comments
 (0)