Module: Shared::Utils::ToCell

Included in:
App::Cell::App, Component::Cell::Dynamic, Page::Cell::Page
Defined in:
app/concepts/shared/utils/to_cell.rb

Instance Method Summary collapse

Instance Method Details

#to_cell(key, component_name, config, argument, children) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/concepts/shared/utils/to_cell.rb', line 3

def to_cell(key, component_name, config, argument, children)
  request_uri = context[:request].env["REQUEST_URI"]
  query_string = context[:request].env["QUERY_STRING"]

  config.merge!(component_key: key)
  config.merge!(children: children)
  config.merge!(origin_url: request_uri.gsub("?" + query_string, ""))
  config.merge!(url_params: context[:params])

  name = component_name.gsub("_", "/")
  if name.include?("/")
    name = "#{name.split("/")[0]}/cell/#{name.split("/")[1]}"
  else
    name = "#{name}/cell/#{name}"
  end

  begin
    concept(name, argument, config)
  rescue
    name = "components/" + name
    concept(name, argument, config)
  end
end