Sha256: 37b104a65f4f7285d8200cb04d4a2b794c9e47147bd21571b16264efa53d32e2

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

module Octogate
  class TargetBuilder
    attr_reader :name

    def initialize(name)
      @name           = name
      @url            = nil
      @username       = nil
      @password       = nil
      @hook_type      = [:push]
      @http_method    = :get
      @parameter_type = :query
      @match          = nil
    end

    def url(url)
      @url = url
    end

    def username(username)
      @username = username
    end

    def password(password)
      @password = password
    end

    def hook_type(types)
      @hook_type = Array(types)
    end

    def http_method(http_method)
      @http_method = http_method
    end

    def parameter_type(parameter_type)
      @parameter_type = parameter_type
    end

    def match(match_proc)
      @match = match_proc
    end

    def params(params)
      @params = params
    end

    def __to_target__
      Target.new(
        url:             @url,
        username:        @username,
        password:        @password,
        hook_type:       @hook_type,
        http_method:     @http_method,
        parameter_type:  @parameter_type,
        params:          @params,
        match:           @match,
      )
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
octogate-0.2.2 lib/octogate/target_builder.rb
octogate-0.2.1 lib/octogate/target_builder.rb
octogate-0.2.0 lib/octogate/target_builder.rb