module Piggybak class ShipppingCalculator::Range < ShippingCalculator KEYS = ["cost", "upper", "lower"] def self.available?(method, object) low_end = method.metadata.detect { |m| m.key == "lower" }.value high_end = method.metadata.detect { |m| m.key == "upper" }.value object.total >= low_end.to_f && object.total <= high_end.to_f end def self.rate(method, object) method.metadata.detect { |m| m.key == "cost" }.value.to_f.to_c end end end