Sha256: a66e0954e10de1f58ab7a4a105b08969c804688a5424349cf83ab267c07eb0ce

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 Bytes

Contents

require 'smspartner/configuration'
require 'smspartner/client'

module Smspartner
  # Configuration builder that is yielded by Smspartner.configure
  class Configurator

    def self.configure
      raise ArgumentError.new('A block is needed for Smspartner.configure') unless block_given?
      builder = new
      yield builder
      Smspartner.configuration = builder.build_config
      Smspartner.client = Client.new(Smspartner.configuration)
    end

    def initialize
      @range_value = :premium
      @sandbox = false
    end

    def build_config
      Configuration.new(
        api_key:     api_key,
        sender:      sender,
        range_value: range_value,
        sandbox:     sandbox
      )
    end

    attr_accessor :api_key, :sender, :range_value, :sandbox

  end

  private_constant :Configurator
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
smspartner-0.1.1 lib/smspartner/configurator.rb
smspartner-0.1.0 lib/smspartner/configurator.rb