module Greeve::Helpers::AttributeToHash
Adds the `#to_h` method.
Public Instance Methods
to_h()
click to toggle source
The (private) `#_attributes` method must be implemented for this method to work.
@return [Hash] a hash of non-nil attributes
# File lib/greeve/helpers/attribute_to_hash.rb, line 9 def to_h _attributes .keys .map { |name| value = __send__(name) value = value.to_a if value.is_a?(Rowset) value = value.to_h if value.is_a?(Namespace) [name, value] } .to_h .reject { |k, v| v.nil? } end