Sha256: c09138345c4ca516df248175e2b7d886acd5ec4056ea8e5af4990cadfa616470

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true
require 'dry-configurable'
require_relative "pears/version"
require_relative "pears/errors"
require_relative "pears/provider"
require_relative "pears/subject"
require_relative "pears/commands"

module Pears
  extend Dry::Configurable

  setting :redis_host, default: :localhost

  def self.subjects
    @subjects ||= []
  end

  # This is the main way of locating a subject.
  def self.subject(name)
    if subjects.any? { |sub| sub.name == name }
      raise Pears::Error.new("subject name #{name} is already in use.")
    end

    Subject.new(name).tap do |subject|
      builder = Provider::Builder.new(subject)
      yield(builder)
      @subjects.push subject
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pears-0.3.0 lib/pears.rb