Sha256: 4d9190411bf8d5c38c842b8601d404d7c401930cc1040301558fe8d12fb73362

Contents?: true

Size: 1.66 KB

Versions: 5

Compression:

Stored size: 1.66 KB

Contents

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

  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

5 entries across 5 versions & 1 rubygems

Version Path
eco-helpers-2.0.38 lib/eco/api/usecases/ooze_samples/ooze_update_case.rb
eco-helpers-2.0.37 lib/eco/api/usecases/ooze_samples/ooze_update_case.rb
eco-helpers-2.0.36 lib/eco/api/usecases/ooze_samples/ooze_update_case.rb
eco-helpers-2.0.35 lib/eco/api/usecases/ooze_samples/ooze_update_case.rb
eco-helpers-2.0.34 lib/eco/api/usecases/ooze_samples/ooze_update_case.rb