Module: React::IsomorphicHelpers
- Defined in:
- lib/reactive-ruby/isomorphic_helpers.rb
Defined Under Namespace
Modules: ClassMethods
Classes: Context, IsomorphicProcCall
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(base) ⇒ Object
3
4
5
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 3
def self.included(base)
base.extend(ClassMethods)
end
|
.load_context(unique_id = nil, name = nil) ⇒ Object
8
9
10
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 8
def self.load_context(ctx, controller, name = nil)
@context = Context.new("#{controller.object_id}-#{Time.now.to_i}", ctx, controller, name)
end
|
.log(message, message_type = :info) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 21
def self.log(message, message_type = :info)
message = [message] unless message.is_a? Array
if message_type == :info
if on_opal_server?
style = 'background: #00FFFF; color: red'
else
style = 'background: #222; color: #bada55'
end
message = ["%c" + message[0], style]+message[1..-1]
`console.log.apply(console, message)`
elsif message_type == :warning
`console.warn.apply(console, message)`
else
`console.error.apply(console, message)`
end
end
|
.on_opal_client? ⇒ Boolean
43
44
45
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 43
def self.on_opal_client?
false
end
|
.on_opal_server? ⇒ Boolean
39
40
41
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 39
def self.on_opal_server?
false
end
|
68
69
70
71
72
73
74
75
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 68
def self.
= Context..collect { |block| block.call }.join("\n")
if RUBY_ENGINE != 'opal'
= ( + "#{@context.send_to_opal(:prerender_footers)}") if @context
= .html_safe
end
end
|
Instance Method Details
#log(*args) ⇒ Object
56
57
58
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 56
def log(*args)
IsomorphicHelpers.log(*args)
end
|
#on_opal_client? ⇒ Boolean
64
65
66
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 64
def on_opal_client?
self.class.on_opal_client?
end
|
#on_opal_server? ⇒ Boolean
60
61
62
|
# File 'lib/reactive-ruby/isomorphic_helpers.rb', line 60
def on_opal_server?
self.class.on_opal_server?
end
|