Class: RSX::Context::ProviderComponent

Inherits:
Object
  • Object
show all
Defined in:
lib/rsx/context.rb

Overview

A component-like object: anything answering to rsx_call can be rendered.

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ ProviderComponent

Returns a new instance of ProviderComponent.



53
54
55
# File 'lib/rsx/context.rb', line 53

def initialize(context)
  @context = context
end

Instance Method Details

#nameObject



57
58
59
# File 'lib/rsx/context.rb', line 57

def name
  "#{@context.name || "Context"}.Provider"
end

#rsx_call(props = nil, _parent = nil) ⇒ Object



61
62
63
64
# File 'lib/rsx/context.rb', line 61

def rsx_call(props = nil, _parent = nil)
  props ||= {}
  @context.with(props[:value]) { RSX.child(props[:children]) }
end