Sha256: f64061adb387bbac92c875af7fd3ac621cf6b9134f6f83cef6e20a45b7ec8ee6

Contents?: true

Size: 901 Bytes

Versions: 4

Compression:

Stored size: 901 Bytes

Contents

# frozen_string_literal: true

require 'dry-container'
require 'dry-auto_inject'
require 'ostruct'

require 'housecanary/version'
require 'housecanary/connection'
require 'housecanary/response_parser'

module Housecanary #:nodoc:
  @container = ::Dry::Container.new
  AutoInject = ::Dry::AutoInject(@container)

  def self.configure
    yield(configuration)
    register!
  end

  def self.container
    @container
  end

  def self.properties
    Housecanary::API::Repository.new
  end

  class << self
    private

    def configuration
      @configuration ||= OpenStruct.new
    end

    def register!
      connection = ::Housecanary::Connection.new(configuration.to_h)
      parser_class = ::Housecanary::ResponseParser
      container.register :connection, -> { connection }
      container.register :response_parser, -> { parser_class }
    end
  end
end

require 'housecanary/api/repository'

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
housecanary-ruby-0.1.3 lib/housecanary.rb
housecanary-ruby-0.1.2 lib/housecanary.rb
housecanary-ruby-0.1.1 lib/housecanary.rb
housecanary-ruby-0.1.0 lib/housecanary.rb