class PIM::Layout

Attributes

layout_opts[R]
model_defined[RW]
modification_status[RW]
name[R]
sections[R]
sort_order[RW]

Public Class Methods

new(name, sections, layout_opts = nil) click to toggle source
# File pim.rb, line 6876
def initialize name, sections, layout_opts = nil
  @model_defined = true;
  @name = name
  @sections = sections
  @layout_opts = layout_opts
  @sort_order = nil
end

Public Instance Methods

==(other) click to toggle source
# File pim.rb, line 6890
def ==(other)
  self.class === other and
    PIM::Utils.is_equal?(name.to_s, other.name.to_s) and
    PIM::Utils.is_equal?(sections, other.sections) and
    PIM::Utils.is_equal?(layout_opts, other.layout_opts) and
    PIM::Utils.is_equal?(modification_status, other.modification_status) and
    PIM::Utils.is_equal?(sort_order, other.sort_order)
end
as_json(opts = {}) click to toggle source
# File pim.rb, line 6899
def as_json opts = {}

  if PIM::Utils.has_opt?(opts, :format, :compact)

    hash = {
      :name => @name.to_s
    }

    sections = {}
    if @sort_order
      @sort_order.each do |section_name|
        section_name = PIM::Utils.to_sym(section_name)
        section = @sections[section_name]
        json = section.as_json(opts) if section
        sections[section_name] = json if json
      end
      # FIXME: What about sections which are NOT in sort_order? -> Same implementation is used in FrontEnd!
    else
      @sections.each do |section_name, section|
        section_name = PIM::Utils.to_sym(section_name)
        json = section.as_json(opts) if section
        sections[section_name] = json if json
      end
    end

    hash[:sections] = sections.values

  else
    hash = {
      :name => @name.to_s,
      :sections => PIM::Utils.as_json(@sections.values),
      :model_defined => @model_defined
    }
    hash[:modification_status] = @modification_status if @modification_status
    hash[:sort_order] = PIM::Utils.as_json(@sort_order) if @sort_order
  end

  if not PIM::Utils.is_empty?(layout_opts)
    hash[:layoutOptions] = {}
    layout_opts.each_pair do |key, value|
      key = PIM::Utils.camelize(key)
      hash[:layoutOptions][key] = PIM::Utils.as_json(value)
    end
  end

  hash

end
attributes() click to toggle source
# File pim.rb, line 6884
def attributes
  attributes = []
  sections.each_value { |s| attributes.keys << s.attributes }
  attributes
end