Sha256: 593145966f5749451c0e5533a5358ee76fc225c6c4fd2dad8198588e347f326b

Contents?: true

Size: 1.25 KB

Versions: 50

Compression:

Stored size: 1.25 KB

Contents

module Eco
  module API
    class Session
      class Config
        class PostLaunch < BaseConfig
          include Enumerable

          def initialize(config:)
            @postcases = []
            super(config: config)
          end

          def length
            count
          end

          def empty?
            count == 0
          end

          def each(params: {}, &block)
            return to_enum(:each) unless block
            items.each(&block)
          end

          def items
            @postcases
          end

          def add(name, type: nil)
            @postcases.push({
              name: name,
              type: type
            })
          end

          def select(usecases)
            raise "Required Eco::API::UseCases to select the target post cases" unless usecases.is_a?(Eco::API::UseCases)
            each_with_object([]) do |pc, targets|
              targets.push(usecases.case(pc[:name], type: pc[:type]))
            end
          end

          private

          def by_name
            @postcases.group_by {|pc| pc[:name]}
          end

          def by_type
            @postcases.group_by {|pc| pc[:type]}
          end

        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
eco-helpers-1.5.1 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.5.0 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.4.2 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.19 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.4.1 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.4.0 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.18 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.17 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.16 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.15 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.14 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.13 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.12 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.11 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.10 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.9 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.8 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.7 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.6 lib/eco/api/session/config/post_launch.rb
eco-helpers-1.3.5 lib/eco/api/session/config/post_launch.rb