Sha256: d0cf8a1a7519ddb817de981016e0f97c9e6f8266a0e2b477c69c0b9003ab7416

Contents?: true

Size: 420 Bytes

Versions: 2

Compression:

Stored size: 420 Bytes

Contents

module Prezzo
  module Explainable
    def self.included(base)
      base.class_eval do
        base.extend(ClassMethods)
      end
    end

    module ClassMethods
      def explain_with(*options)
        define_method(:explain) do
          explanation = {}

          options.each do |method|
            explanation[method] = send(method)
          end

          explanation
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prezzo-0.3.0 lib/prezzo/explainable.rb
prezzo-0.2.2 lib/prezzo/explainable.rb