Class: ConvenientService::Support::Cache::Entities::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/support/cache/entities/key.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args, **kwargs, &block) ⇒ void

Parameters:

  • args (Array<Object>)
  • kwargs (Hash{Symbol => Object})
  • block (Proc, nil)


14
15
16
17
18
# File 'lib/convenient_service/support/cache/entities/key.rb', line 14

def initialize(*args, **kwargs, &block)
  @args = args
  @kwargs = kwargs
  @block = block
end

Instance Method Details

#==(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


24
25
26
27
28
29
30
31
32
# File 'lib/convenient_service/support/cache/entities/key.rb', line 24

def ==(other)
  return unless other.instance_of?(self.class)

  return false if args != other.args
  return false if kwargs != other.kwargs
  return false if block&.source_location != other.block&.source_location

  true
end

#eql?(other) ⇒ Boolean?

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)


46
47
48
49
50
51
52
53
54
# File 'lib/convenient_service/support/cache/entities/key.rb', line 46

def eql?(other)
  return unless other.instance_of?(self.class)

  return false if args != other.args
  return false if kwargs != other.kwargs
  return false if block&.source_location != other.block&.source_location

  true
end

#hashObject



87
88
89
# File 'lib/convenient_service/support/cache/entities/key.rb', line 87

def hash
  [args, kwargs, block&.source_location].hash
end