lib/minitext.rb in minitext-0.0.8 vs lib/minitext.rb in minitext-1.0.0

- old
+ new

@@ -1,32 +1,29 @@ +# frozen_string_literal: true + +require_relative "minitext/allowlist_proxy" +require_relative "minitext/configuration" +require_relative "minitext/message" +require_relative "minitext/test_gateway" +require_relative "minitext/twilio_gateway" +require_relative "minitext/version" + module Minitext - autoload :Message, 'minitext/message' - autoload :MissingParameter, 'minitext/missing_parameter' - autoload :TestGateway, 'minitext/test_gateway' - autoload :TwilioGateway, 'minitext/twilio_gateway' - autoload :WhitelistProxy, 'minitext/whitelist_proxy' + class Error < StandardError; end - def self.gateway - @gateway ||= TestGateway.new + def self.configuration + @configuration ||= Configuration.new end - def self.gateway=(gateway) - @gateway = gateway + def self.configure(&block) + yield(configuration) end - def self.defaults - @defaults ||= {} - {gateway: gateway}.merge(@defaults) + def self.gateway + configuration.gateway end - def self.defaults=(defaults) - @defaults = defaults + def self.text(**kwargs) + Message.new(**configuration.message_defaults.merge(gateway: configuration.gateway).merge(kwargs)) end - - def self.text(params) - Message.new(defaults.merge(params)) - end end -if defined?(Rails) - require 'minitext/railtie' -end