Class: Bunny::RecordedExchange

Inherits:
RecordedNamedEntity show all
Defined in:
lib/bunny/topology_registry.rb

Overview

Represents an exchange declaration intent that can be repeated.

Instance Attribute Summary collapse

Attributes inherited from RecordedNamedEntity

#name

Attributes inherited from RecordedEntity

#channel

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ch, name) ⇒ RecordedExchange

Returns a new instance of RecordedExchange.

Parameters:



479
480
481
482
483
484
485
486
# File 'lib/bunny/topology_registry.rb', line 479

def initialize(ch, name)
  super(ch, name)

  @type = nil
  @durable = true
  @auto_delete = false
  @arguments = nil
end

Instance Attribute Details

#argumentsHash (readonly)

Returns:

  • (Hash)


475
476
477
# File 'lib/bunny/topology_registry.rb', line 475

def arguments
  @arguments
end

#auto_deleteBoolean (readonly)

Returns:

  • (Boolean)


473
474
475
# File 'lib/bunny/topology_registry.rb', line 473

def auto_delete
  @auto_delete
end

#durableBoolean (readonly)

Returns:

  • (Boolean)


471
472
473
# File 'lib/bunny/topology_registry.rb', line 471

def durable
  @durable
end

#typeString (readonly)

Returns:

  • (String)


469
470
471
# File 'lib/bunny/topology_registry.rb', line 469

def type
  @type
end

Class Method Details

.from(x) ⇒ Object

Parameters:



540
541
542
543
544
545
546
# File 'lib/bunny/topology_registry.rb', line 540

def self.from(x)
  new(x.channel, x.name)
    .with_type(x.type)
    .with_durable(x.durable?)
    .with_auto_delete(x.auto_delete?)
    .with_arguments(x.arguments)
end

Instance Method Details

#==(other) ⇒ Boolean

Returns:

  • (Boolean)


529
530
531
532
533
534
535
536
537
# File 'lib/bunny/topology_registry.rb', line 529

def ==(other)
  other.class == self.class &&
    other.name == self.name &&
    other.channel == self.channel &&
    other.durable == self.durable &&
    other.auto_delete == self.auto_delete &&
    other.type == self.type &&
    other.arguments == self.arguments
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


524
525
526
# File 'lib/bunny/topology_registry.rb', line 524

def eql?(other)
  self == other
end

#hashInteger

Returns:

  • (Integer)


519
520
521
# File 'lib/bunny/topology_registry.rb', line 519

def hash
  [self.class, self.channel, self.name, @type, @durable, @auto_delete, @arguments].hash
end

#predefined?Boolean Also known as: predeclared?

Returns true if this exchange is a pre-defined one (amq.direct, amq.fanout, amq.match and so on).

Returns:

  • (Boolean)

    true if this exchange is a pre-defined one (amq.direct, amq.fanout, amq.match and so on)



489
490
491
# File 'lib/bunny/topology_registry.rb', line 489

def predefined?
  (@name == AMQ::Protocol::EMPTY_STRING) || !!(@name =~ /^amq\.(direct|fanout|topic|headers|match)/i)
end

#with_arguments(value) ⇒ Object

Parameters:

  • value (Hash)


513
514
515
516
# File 'lib/bunny/topology_registry.rb', line 513

def with_arguments(value)
  @arguments = value
  self
end

#with_auto_delete(value) ⇒ Object

Parameters:

  • value (Boolean)


501
502
503
504
# File 'lib/bunny/topology_registry.rb', line 501

def with_auto_delete(value)
  @auto_delete = value
  self
end

#with_durable(value) ⇒ Object

Parameters:

  • value (Boolean)


495
496
497
498
# File 'lib/bunny/topology_registry.rb', line 495

def with_durable(value)
  @durable = value
  self
end

#with_type(value) ⇒ Object

Parameters:

  • value (Symbol)


507
508
509
510
# File 'lib/bunny/topology_registry.rb', line 507

def with_type(value)
  @type = value
  self
end