Module: TypeformData::ComparableByIdAndConfig

Includes:
Comparable
Included in:
Typeform, Typeform::Answer, Typeform::Field, Typeform::Question, Typeform::Response
Defined in:
lib/typeform_data/comparable_by_id_and_config.rb

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



18
19
20
21
22
23
# File 'lib/typeform_data/comparable_by_id_and_config.rb', line 18

def <=>(other)
  unless other.respond_to?(:sort_key)
    raise TypeformData::ArgumentError, "#{other.inspect} does not specify a sort key"
  end
  other.sort_key <=> sort_key
end

#==(other) ⇒ Object



11
12
13
14
15
16
# File 'lib/typeform_data/comparable_by_id_and_config.rb', line 11

def ==(other)
  unless other.respond_to?(:sort_key, true) && other.respond_to?(:config, true)
    raise TypeformData::ArgumentError, "#{other.inspect} does not specify a sort key and config"
  end
  other.sort_key == sort_key && other.config == config
end

#sort_keyObject

Override this method to specify a different key.



7
8
9
# File 'lib/typeform_data/comparable_by_id_and_config.rb', line 7

def sort_key
  id
end