Skip to content
This repository was archived by the owner on Oct 19, 2018. It is now read-only.

Commit 57e0d6f

Browse files
committed
Add universal / isormorphic React::Config
1 parent a41aca3 commit 57e0d6f

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

lib/react/config.rb.erb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
if RUBY_ENGINE != 'opal'
2+
module React
3+
module Config
4+
extend self
5+
def environment=(value)
6+
config[:environment] = value
7+
end
8+
9+
def config
10+
@config ||= default_config
11+
end
12+
13+
def default_config
14+
{
15+
environment: ENV['RACK_ENV'] || 'development'
16+
}
17+
end
18+
end
19+
end
20+
else
21+
module React
22+
module Config
23+
extend self
24+
def environment=(value)
25+
raise "Environment cannot be configured at runtime."
26+
end
27+
28+
def config
29+
hash = %x{
30+
Opal.hash({
31+
environment: <%= '"' + React::Config.config[:environment] + '"' %>
32+
})
33+
}
34+
hash
35+
end
36+
end
37+
end
38+
end

0 commit comments

Comments
 (0)