module AtomicCms::Editor::ClassMethods

Public Instance Methods

from_array(hash) click to toggle source
# File lib/atomic_cms/editor.rb, line 38
def from_array(hash)
  array = []
  hash.each do |_, element|
    array << from_hash(element)
  end
  array
end
from_hash(params) click to toggle source
# File lib/atomic_cms/editor.rb, line 32
def from_hash(params)
  h.component(params.delete(:template_name)).tap do |obj|
    params.each { |key, val| obj.options[key.to_sym] = from_value(key, val) }
  end
end
from_value(key, value) click to toggle source
# File lib/atomic_cms/editor.rb, line 46
def from_value(key, value)
  return from_array(value) if key == 'children'
  return from_hash(value) if Hash == value
  return nil if value.empty?
  value
end