Class: ReactiveRuby::Rails::ComponentMount

Inherits:
React::Rails::ComponentMount
  • Object
show all
Defined in:
lib/reactive-ruby/rails/component_mount.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#controllerObject

Returns the value of attribute controller.



4
5
6
# File 'lib/reactive-ruby/rails/component_mount.rb', line 4

def controller
  @controller
end

Instance Method Details

#react_component(name, props = {}, options = {}, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/reactive-ruby/rails/component_mount.rb', line 10

def react_component(name, props = {}, options = {}, &block)
  if options[:prerender] || [:on, 'on', true].include?(Hyperloop.prerendering)
    options = context_initializer_options(options, name)
  end
  props = serialized_props(props, name, controller)
  result = super(top_level_name, props, options, &block).gsub("\n","")
  result = result.gsub(/(<script.*<\/script>)<\/div>$/,'</div>\1').html_safe
  result + footers
end

#setup(controller) ⇒ Object



6
7
8
# File 'lib/reactive-ruby/rails/component_mount.rb', line 6

def setup(controller)
  self.controller = controller
end