lib/much-result.rb in much-result-0.1.1 vs lib/much-result.rb in much-result-0.1.2
- old
+ new
@@ -75,10 +75,18 @@
def set(**kargs)
@data = ::OpenStruct.new((@data || {}).to_h.merge(**kargs))
self
end
+ def attributes
+ @data.to_h.reject { |key, _| key.to_s.start_with?("much_result_") }
+ end
+
+ def attribute_names
+ attributes.keys
+ end
+
def success?
if @success_predicate.nil?
@success_predicate =
@sub_results.reduce(@result_value == MuchResult::SUCCESS) { |acc, result|
acc && result.success?
@@ -195,10 +203,11 @@
def inspect
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} "\
"#{success? ? "SUCCESS" : "FAILURE"} "\
"#{"@description=#{@description.inspect} " if @description}"\
- "@sub_results=#{@sub_results.inspect}>"
+ "@sub_results=#{@sub_results.inspect} "\
+ "attribute_names: #{attribute_names}>"
end
private
def build_default_capture_exception