Class: MR

Inherits:
Object
  • Object
show all
Defined in:
lib/multi_render/mr.rb

Instance Method Summary collapse

Constructor Details

#initializeMR

Returns a new instance of MR.



2
3
4
# File 'lib/multi_render/mr.rb', line 2

def initialize
  @data = {}
end

Instance Method Details

#add(name, route, data) ⇒ Object



6
7
8
9
10
11
# File 'lib/multi_render/mr.rb', line 6

def add(name, route, data)
  @data[name.to_s] = {
    data_array: data,
    render_partial: ->(x) {x.call({partial: route, locals: @data[name.to_s][:data_array]})}
  }
end

#get_dataObject



17
18
19
# File 'lib/multi_render/mr.rb', line 17

def get_data
  @data
end

#render_partial(name, _render) ⇒ Object



13
14
15
# File 'lib/multi_render/mr.rb', line 13

def render_partial(name, _render)
  @data[name.to_s][:render_partial].call(_render)
end