Module: AtomicCms::Editor::ClassMethods
- Defined in:
- lib/atomic_cms/editor.rb
Instance Method Summary collapse
Instance Method Details
#from_array(hash) ⇒ Object
38 39 40 41 42 43 44 |
# 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) ⇒ Object
32 33 34 35 36 |
# 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.[key.to_sym] = from_value(key, val) } end end |
#from_value(key, value) ⇒ Object
46 47 48 49 50 51 |
# 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 |