Sha256: 05f500f9eb6e8c56ed6c2b9a9bdc64096f3bc0d9827ed871418bca3c321816b9

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

Contents

module LicenseFinder
  module CLI
    module MakesDecisions
      def self.included(mod)
        mod.extend(ClassMethods)
      end

      module ClassMethods
        def auditable
          method_option :who, desc: "The person making this decision"
          method_option :why, desc: "The reason for making this decision"
        end
      end

      private

      def say_each(coll)
        if coll.any?
          coll.each do |item|
            say(block_given? ? yield(item) : item)
          end
        else
          say '(none)'
        end
      end

      def txn
        @txn ||= {
          who: options[:who],
          why: options[:why],
          when: Time.now.getutc
        }
      end

      def modifying
        # decisions = Decisions.saved! # is part of Base
        yield
        decisions.save!(config.decisions_file)
      end

      def modify_each(*things)
        modifying { things.each { |thing| yield thing } }
        things
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
license_finder-2.0.0.rc2 lib/license_finder/cli/makes_decisions.rb