class Ecoportal::API::V2::Page::Section
Public Class Methods
new_doc(split: false)
click to toggle source
# File lib/ecoportal/api/v2/page/section.rb, line 7 def new_doc(split: false) { "id" => new_uuid, "type" => split ? "split" : "content", "weight" => 9999 }.tap do |out| component_ids = if split { "left_component_ids" => [], "right_component_ids" => [] } else { "component_ids" => [] } end out.merge!(component_ids) end end
Public Instance Methods
all_component_ids()
click to toggle source
# File lib/ecoportal/api/v2/page/section.rb, line 38 def all_component_ids return component_ids.to_a unless split? left_component_ids.to_a | right_component_ids.to_a end
component?(id)
click to toggle source
# File lib/ecoportal/api/v2/page/section.rb, line 43 def component?(id) all_component_ids.include?(id) end
components() { |fld| ... }
click to toggle source
# File lib/ecoportal/api/v2/page/section.rb, line 47 def components fld_ids = all_component_ids root.components.values_at(*fld_ids).select.with_index do |fld, i| puts "Warning: field #{id} points to missing field #{fld_ids[i]}" if !fld fld && (!block_given? || yield(fld)) end end
split?()
click to toggle source
# File lib/ecoportal/api/v2/page/section.rb, line 34 def split? doc && doc["type"] == "split" end