Class: Gardefou::CallSignature

Inherits:
Object
  • Object
show all
Defined in:
lib/gardefou/storage.rb

Overview

Utility class for creating call signatures for duplicate detection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fn_name, args, kwargs) ⇒ CallSignature

Returns a new instance of CallSignature.



9
10
11
12
13
# File 'lib/gardefou/storage.rb', line 9

def initialize(fn_name, args, kwargs)
  @fn_name = fn_name
  @args = args
  @kwargs = kwargs
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



7
8
9
# File 'lib/gardefou/storage.rb', line 7

def args
  @args
end

#fn_nameObject (readonly)

Returns the value of attribute fn_name.



7
8
9
# File 'lib/gardefou/storage.rb', line 7

def fn_name
  @fn_name
end

#kwargsObject (readonly)

Returns the value of attribute kwargs.



7
8
9
# File 'lib/gardefou/storage.rb', line 7

def kwargs
  @kwargs
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



25
26
27
# File 'lib/gardefou/storage.rb', line 25

def ==(other)
  other.is_a?(CallSignature) && to_s == other.to_s
end

#hashObject



29
30
31
# File 'lib/gardefou/storage.rb', line 29

def hash
  to_s.hash
end

#to_sObject



15
16
17
18
19
20
21
22
23
# File 'lib/gardefou/storage.rb', line 15

def to_s
  # Create deterministic string representation
  sorted_kwargs = @kwargs.sort.to_h
  {
    fn_name: @fn_name,
    args: @args,
    kwargs: sorted_kwargs
  }.to_json
end