Module: Rack::Component::Methods

Included in:
Rack::Component
Defined in:
lib/rack/component.rb

Overview

Rack::Component::Methods instead.

class POROGreeter
  extend Rack::Component::Methods
  render { "Hi, #{env[:name]" }
end

Examples:

If you don’t want to subclass, you can extend

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



21
22
23
# File 'lib/rack/component.rb', line 21

def self.extended(base)
  base.include(InstanceMethods)
end

Instance Method Details

#call(env = {}, &children) ⇒ Object



29
30
31
# File 'lib/rack/component.rb', line 29

def call(env = {}, &children)
  new(env).render(&children)
end

#render(opts = {}) ⇒ Object



25
26
27
# File 'lib/rack/component.rb', line 25

def render(opts = {})
  block_given? ? configure_block(Proc.new) : configure_template(opts)
end