lib/repeatable/expression/date.rb in repeatable-1.0.0 vs lib/repeatable/expression/date.rb in repeatable-1.1.0
- old
+ new
@@ -1,30 +1,34 @@
+# typed: strict
module Repeatable
module Expression
class Date < Base
- def to_h
- Hash[hash_key, attributes]
- end
+ abstract!
+ sig { params(other: Object).returns(T::Boolean) }
def ==(other)
other.is_a?(self.class) && attributes == other.attributes
end
-
alias_method :eql?, :==
+ sig { returns(Integer) }
def hash
[attributes.values, self.class.name].hash
end
protected
+ sig { returns(Types::SymbolHash) }
def attributes
instance_variables.each_with_object({}) do |name, hash|
- key = name.to_s.gsub(/^@/, "").to_sym
- hash[key] = normalize_attribute_value(instance_variable_get(name))
+ key = name.to_s.gsub(/^@/, "")
+ next if key.start_with?("_")
+ hash[key.to_sym] = normalize_attribute_value(instance_variable_get(name))
end
end
+ alias_method :hash_value, :attributes
+ sig { params(value: BasicObject).returns(T.untyped) }
def normalize_attribute_value(value)
case value
when ::Date
value.to_s
else