lib/prezzo/calculator.rb in prezzo-0.5.1 vs lib/prezzo/calculator.rb in prezzo-1.0.0.pre.rc
- old
+ new
@@ -1,22 +1,28 @@
module Prezzo
module Calculator
+ def self.included(base)
+ base.class_eval do
+ base.include(ParamsDSL)
+ base.include(ComponentsDSL)
+ base.include(TransientDSL)
+ base.include(Explainable)
+ end
+ end
+
def initialize(context = {})
- @context = validated!(context)
+ @context = context
end
def calculate
- raise "Calculate not implemented"
+ @total ||= formula
end
+ def formula
+ raise "Formula not implemented"
+ end
+
private
attr_reader :context
-
- def validated!(context)
- raise "Empty Context" if context.nil?
- raise "Invalid Context" if context.respond_to?(:valid?) && !context.valid?
-
- context
- end
end
end