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:



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

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

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

Instance Attribute Details

#argumentsHash (readonly)

Returns:

  • (Hash)


477
478
479
# File 'lib/bunny/topology_registry.rb', line 477

def arguments
  @arguments
end

#auto_deleteBoolean (readonly)

Returns:

  • (Boolean)


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

def auto_delete
  @auto_delete
end

#durableBoolean (readonly)

Returns:

  • (Boolean)


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

def durable
  @durable
end

#typeString (readonly)

Returns:

  • (String)


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

def type
  @type
end

Class Method Details

.from(x) ⇒ Object

Parameters:



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

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)


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

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)


526
527
528
# File 'lib/bunny/topology_registry.rb', line 526

def eql?(other)
  self == other
end

#hashInteger

Returns:

  • (Integer)


521
522
523
# File 'lib/bunny/topology_registry.rb', line 521

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)



491
492
493
# File 'lib/bunny/topology_registry.rb', line 491

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

#with_arguments(value) ⇒ Object

Parameters:

  • value (Hash)


515
516
517
518
# File 'lib/bunny/topology_registry.rb', line 515

def with_arguments(value)
  @arguments = value
  self
end

#with_auto_delete(value) ⇒ Object

Parameters:

  • value (Boolean)


503
504
505
506
# File 'lib/bunny/topology_registry.rb', line 503

def with_auto_delete(value)
  @auto_delete = value
  self
end

#with_durable(value) ⇒ Object

Parameters:

  • value (Boolean)


497
498
499
500
# File 'lib/bunny/topology_registry.rb', line 497

def with_durable(value)
  @durable = value
  self
end

#with_type(value) ⇒ Object

Parameters:

  • value (Symbol)


509
510
511
512
# File 'lib/bunny/topology_registry.rb', line 509

def with_type(value)
  @type = value
  self
end