lib/prezzo/calculator.rb in prezzo-0.1.0 vs lib/prezzo/calculator.rb in prezzo-0.2.0
- old
+ new
@@ -1,15 +1,22 @@
module Prezzo
- class Calculator
+ module Calculator
def initialize(context = {})
- @context = context
+ @context = validated!(context)
end
def calculate
- 0
+ raise "Calculate not implemented"
end
private
+
+ def validated!(context)
+ raise "Empty Context" if context.nil?
+ raise "Invalid Context" if context.respond_to?(:valid?) && !context.valid?
+
+ context
+ end
def context
@context
end
end