Class: LucidWorks::Cluster::Shard

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serializers::JSON
Defined in:
lib/lucid_works/cluster.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node, name, collection, leader) ⇒ Shard

Returns a new instance of Shard.



33
34
35
36
37
38
39
# File 'lib/lucid_works/cluster.rb', line 33

def initialize(node, name, collection, leader)
  @id = "#{collection}_#{name}"
  @node = node
  @name = name
  @collection = collection
  @leader = leader
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



30
31
32
# File 'lib/lucid_works/cluster.rb', line 30

def collection
  @collection
end

#idObject (readonly)

Returns the value of attribute id.



30
31
32
# File 'lib/lucid_works/cluster.rb', line 30

def id
  @id
end

#leaderObject (readonly) Also known as: leader?

Returns the value of attribute leader.



30
31
32
# File 'lib/lucid_works/cluster.rb', line 30

def leader
  @leader
end

#nameObject (readonly)

Returns the value of attribute name.



30
31
32
# File 'lib/lucid_works/cluster.rb', line 30

def name
  @name
end

#nodeObject (readonly)

Returns the value of attribute node.



30
31
32
# File 'lib/lucid_works/cluster.rb', line 30

def node
  @node
end

Instance Method Details

#==(other) ⇒ Object



45
46
47
# File 'lib/lucid_works/cluster.rb', line 45

def ==(other)
  node == other.node && name == other.name && collection == other.collection
end

#as_json(options = {}) ⇒ Object



41
42
43
# File 'lib/lucid_works/cluster.rb', line 41

def as_json(options = {})
  {'name' => name, 'collection' => collection, 'leader' => leader}
end