lib/suricate/widgets/responses/counter_widget_response.rb in suricate-0.0.2 vs lib/suricate/widgets/responses/counter_widget_response.rb in suricate-0.0.3

- old
+ new

@@ -1,18 +1,21 @@ module Suricate - class CounterWidgetResponse + class CounterWidgetResponse < WidgetResponse class NotAnNumberError < StandardError; end def initialize @value = nil + super end def value(value) raise NotAnNumberError.new("#{value} is not a number") unless value.is_a?(Numeric) @value = value end def to_h - { value: @value } + super.tap do |hash| + hash.merge!(value: @value) + end end end end