Sha256: d5283992ca5767d8ddeda99bc730d9427b073a6d53e527c9a211fbab8ea52897

Contents?: true

Size: 716 Bytes

Versions: 2

Compression:

Stored size: 716 Bytes

Contents

require 'forwardable'
require 'jot/ruby/version'
require 'jot/ruby/errors'
require 'jot/ruby/utils'
require 'jot/ruby/operation'
require 'jot/ruby/impl_base'

module Jot
  module Ruby
    class << self
      def init(impl_name = nil)
        impl_const = Jot::Ruby.impl_registry[impl_name.to_s]
        impl_const ||= Jot::Ruby.impl_registry.values.first
        raise Errors::NoImplError unless impl_const
        self.impl = impl_const.new
      end

      extend Forwardable
      def_delegators :impl, *Jot::Ruby::ImplBase::DEFAULT_METHODS

      def impl_registry
        @impl_registry ||= {}
      end

      private

      attr_writer :impl

      def impl
        @impl ||= init
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jot-ruby-0.1.4 lib/jot/ruby.rb
jot-ruby-0.1.3 lib/jot/ruby.rb