Sha256: d4cb71ea2ea0d25210a0b87729937435ab58101f95f9544b7154cc9d6c74478f

Contents?: true

Size: 446 Bytes

Versions: 2

Compression:

Stored size: 446 Bytes

Contents

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

    module ClassMethods
      def composed_by(options)
        @@__calculators = {}

        options.each do |name, klass|
          @@__calculators[name] = klass

          define_method(name) do
            @@__calculators[name].new(context).calculate
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
prezzo-0.2.1 lib/prezzo/composed.rb
prezzo-0.2.0 lib/prezzo/composed.rb