Sha256: d1e5e336712f6a0779d001eb4fbf980e2c4469ecaa2094f7429b82dd023fdc9e

Contents?: true

Size: 453 Bytes

Versions: 2

Compression:

Stored size: 453 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)
        @@_methods = options

        define_method(:explain) do
          explanation = {}

          @@_methods.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.2.1 lib/prezzo/explainable.rb
prezzo-0.2.0 lib/prezzo/explainable.rb