Sha256: a39dc28a3efba7ae597627d180bab8d99c2c53f7fb641f9e03825a069207d551

Contents?: true

Size: 1.92 KB

Versions: 1

Compression:

Stored size: 1.92 KB

Contents

class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::UseCases::OozeSamples::OozeRunBaseCase
  name "single-ooze-case"
  type :other

  include Eco::API::UseCases::OozeSamples::Helpers

  def main(session, options, usecase)
    raise "You need to inherit from this class and call super with a block" unless block_given?
    super(session, options, usecase) do
      yield
    end
  end

  private

  def with_fields(type: nil, label: nil)
    flds = target.components
    flds = flds.get_by_type(type) if type
    flds = flds.select do |fld|
      value = (label == :unnamed) ? nil : label
      !label || same_string?(fld.label, value)
    end.each do |field|
      yield(field) if block_given?
    end
  end

  def with_sections(type: nil, heading: nil)
    secs = target.sections
    secs = secs.get_by_type(type) if type
    secs = secs.select do |sec|
      value = (heading == :unnamed) ? nil : heading
      !heading || same_string?(sec.heading, value)
    end.each do |sec|
      yield(sec) if block_given?
    end
  end

  def with_stage(name:)
    if stage = target.stages.get_by_name(name)
      yield(stage) if block_given?
    end
    stage
  end

  def add_field(name, type, section, after:  nil, side: :left)
    raise "You need to specify a section for a new field. Given: #{section.class}" unless section.is_a?(Ecoportal::API::V2::Page::Section)
    target.components.add(label: name, type: type) do |field|
      section.add_component(field, after: after, side: side)
    end.tap do |field|
      yield(field) if block_given?
    end
  end

  def to_field(value)
    fld   = nil
    fld ||= value if value.is_a?(Ecoportal::API::V2::Page::Component)
    fld ||= target.components.get_by_id(value)
    fld ||= target.components.select {|fld| same_name?(fld.label, value)}
    #fld ||= value.reference if value.is_a?(Ecoportal::API::V2::Page::Force::Binding)
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eco-helpers-2.0.33 lib/eco/api/usecases/ooze_samples/ooze_update_case.rb