Sha256: f2237627c2257427c4ec18d3b17f84732578e30c8143f7a9c9ac0387ea3f6d68

Contents?: true

Size: 402 Bytes

Versions: 3

Compression:

Stored size: 402 Bytes

Contents

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

    module ClassMethods
      def composed_by(options)
        options.each do |name, klass|
          options[name] = klass

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
prezzo-0.4.0 lib/prezzo/composable.rb
prezzo-0.3.1 lib/prezzo/composable.rb
prezzo-0.3.0 lib/prezzo/composable.rb