Sha256: 7eb9ed121ea23190fa19acd980d4ccab1fd45b7220c8932578470ddc2333a824

Contents?: true

Size: 753 Bytes

Versions: 2

Compression:

Stored size: 753 Bytes

Contents

require 'forwardable'

module Sunzi
  class Actions < Thor
    # This class exists because thor has to be inherited AND included to import actions.
    #
    # https://github.com/erikhuda/thor/wiki/Actions
    #
    # This interface is ugly. Instead, initialize once and reuse everywhere.

    include Thor::Actions

    source_root GemRoot

    # include this module to use delegate_to_thor method.
    module Delegate
      def self.included(base)
        base.extend Forwardable
        base.extend ClassMethods
      end

      module ClassMethods
        def delegate_to_thor(*args)
          def_delegators :'Sunzi.thor', *args
        end
      end
    end
  end

  class << self
    def thor
      @thor ||= Sunzi::Actions.new
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sunzi-2.1.0 lib/sunzi/actions.rb
sunzi-2.0.0 lib/sunzi/actions.rb