class Ecoportal::API::V2::Page::Components

Public Instance Methods

add(label:, type:) { |fld| ... } click to toggle source
# File lib/ecoportal/api/v2/page/components.rb, line 35
def add(label:, type:)
  fld_doc = component_class.new_doc(type: type)
  upsert!(fld_doc) do |fld|
    fld.label  = label
    yield(fld) if block_given?
  end
end
get_by_id(id) click to toggle source
# File lib/ecoportal/api/v2/page/components.rb, line 16
def get_by_id(id)
  self.find do |comp|
    comp.id == id
  end
end
get_by_name(name, type: nil) click to toggle source
# File lib/ecoportal/api/v2/page/components.rb, line 28
def get_by_name(name, type: nil)
  pool = type ? get_by_type(type) : self
  pool.select do |comp|
    same_string?(comp.label, name)
  end
end
get_by_type(type) click to toggle source
# File lib/ecoportal/api/v2/page/components.rb, line 22
def get_by_type(type)
  self.select do |comp|
    comp.type.downcase == type.to_s.strip.downcase
  end
end