Sha256: a2a021041e68cbd68fff9a9013d694a4bdfd614967068388699b7bc216f51413

Contents?: true

Size: 727 Bytes

Versions: 4

Compression:

Stored size: 727 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, &block)
    if subjects.any? { |sub| sub.name == name }
      raise Pears::Error.new("subject name #{name} is already in use.")
    end

    Subject.new(name, loader: block).tap { |sub| @subjects.push sub }
  end

  def self.[](name)
    subjects.find { |subject| subject.name == name }
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pears-0.3.5 lib/pears.rb
pears-0.3.4 lib/pears.rb
pears-0.3.2 lib/pears.rb
pears-0.3.1 lib/pears.rb